Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save the state of radio button (Urgent!!!)

Status
Not open for further replies.

menu

Technical User
Apr 25, 2001
24
AE
Hi,

Can anyone help me with the problem below:
the selected radio button determines if they are from the US or a different country.Depending on that you should enter zipcode or postalcode.The problem is that if they type in values for both postalcode and zipcode,both values are inserted into the DB which is not the solution wanted.
Actually only the selected radio button values should be inserted by saving the toggle state of it and the rest should be ignored even though the user entered in both of them.

<cfform action=
 
Hum I dont have your form here but I will give you a solution anyway.

<FORM ACTION=&quot;test.cfm&quot;>

<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;COUNTRY&quot; VALUE=&quot;USA&quot; CHECKED>USA
<INPUT TYPE=&quot;checkbox&quot; NAME=&quot;COUNTRY&quot; VALUE=&quot;OTHER&quot;>OTHER

<INPUT TYPE=&quot;text&quot; NAME=&quot;postalCode&quot;>
<INPUT TYPE=&quot;text&quot; NAME=&quot;ZipCode&quot;>

</FORM>

In test.cfm when adding in the db:

<CFQUERY NAME=&quot;test&quot; DATASOURCE=&quot;yourDataSource&quot;>
INSERT INTO yourTableName
(

put your other fields here

<CFIF country EQ &quot;USA&quot;>
,zipCode
</CFIF>
<CFIF country EQ &quot;OTHER&quot;>
,postalCode
</CFIF>
)
values
(

put your other fields here

<CFIF country EQ &quot;USA&quot;>
,#zipCode#
</CFIF>
<CFIF country EQ &quot;OTHER&quot;>
,#postalCode#
</CFIF>
)

I hope this help!



 
Hi,
Thanks for the help.But it's giving me an ODBC error.
The query is

<!--- updates the DB with profile info. provided by the user who is a member --->
<CFQUERY name=&quot;updateProf&quot; datasource=#CONST_DB_NAME# dbtype=#CONST_DB_TYPE#>
UPDATE memprofiledata
SET birth_month = '#month#', gender='#gender#', birth_day=#day#, birth_year=#year#, ology_name_id_ref=#ologyid#,
<CFIF #Form.country# IS USA>
zipcode=#zipcode#,
<CFELSE>
country_id_ref=#countryid#,
postal_code=#postalcode#,
</CFIF>
WHERE member_id_ref = #session.memID#
</CFQUERY>
Thanks,
Jane.
 
Hi! for sure this will give ya an ODBC error!

<!--- updates the DB with profile info. provided by the user who is a member --->
<CFQUERY name=&quot;updateProf&quot; datasource=#CONST_DB_NAME# dbtype=#CONST_DB_TYPE#>
UPDATE memprofiledata
SET birth_month = '#month#', gender='#gender#', birth_day='#day#', birth_year='#year#', ology_name_id_ref=#ologyid#,
<CFIF #Form.country# IS &quot;USA&quot;>
zipcode='#zipcode#'
<CFELSE>
country_id_ref=#countryid#,
postal_code='#postalcode#'
</CFIF>
WHERE member_id_ref = #session.memID#
</CFQUERY>

try this one it will work...

Too many &quot;,&quot; in your query!
I added some &quot;'&quot; too...
be sure to check your data type... if you still get an error please tell me the error msg next time...
 
Hi,

That worked.Thanks a lot.

Jane.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top