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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox values??

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
Hi,

I need to assign 2 values to a checkbox.
What I am trying to do is insert the value of a checkbox into a database where if the box is checked then "Not Applicable" is inserted to the database & if not checked then "No" is inserted.
e.g.

<input type=&quot;checkbox&quot; name=&quot;stage1_app&quot; value=&quot;Not Applicable&quot; defaultvalue=&quot;No&quot;>

This kicks up an error. SOOOOOoooooo ayone got any ideas how to do this?? Please.. I dont want to go to Chelsea!!!
 
Well, you can only have one value for the checkbox -- What I usually do is make the value=1 and then evaluate the value of it on the subsequent page, and then take action.

If you're using ASP, then this is what it would look like on the subsequent page using this method:

<%
if request.form(&quot;stage1_app&quot;) = &quot;1&quot; then
insertValue = &quot;Not Applicable&quot;
else
insertValue = &quot;No&quot;
end if
%>

Then go ahead and do what you need to do with the new vbScript variable, insertValue.

:)
Paul Prewett
 
u can try this

have a hidden field and when a person checks the checkbox then change the value of the checkbox to whatever you want

but you have to use javascript for that

regards Unicorn11
unicorn11@mailcity.com

[red]Luck is not chance, it's toil; fortune's expensive
smile is earned.[red]
 
Cheers guys.

I realised that in the end I actualy needed 1 of 3 values to end up in the database so I have ended up using a dropdown instead.

That'll teach me to fully scope a project before I start programming. :)
I dont want to go to Chelsea!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top