Welcome Guest, Not a member yet? Register   Sign In
Checkbox Values
#8

[eluser]sketchynix[/eluser]
Quote:When you uncheck it, it sets the value to 0.. (it doesn’t know that you really want “N” ... how could it? there’s no way to tell it so)... It wouldn’t surprise me to find out that if you uncheck, and then re-check the checkbox, you get either 1 or -1 as the value.

Not in HTML. The browser will send nothing if the checkbox isn't selected. If it is selected and the value attribute isnt set to anything, the browser will send the variable value as "on".
It is a bit bizarre, but it makes sense if you think of a series of IDs being sent by checkboxes. If one of the IDs is 0 and the user checks the box, the value of the variable would come across as 0, if the browser typically sent a 0 for unchecked boxes, your script would interpret it as not being set. By not sending it at all, you just have to check to see if it exists and thereby have more flexibility in what values you can use in the form.


Messages In This Thread
Checkbox Values - by El Forum - 09-28-2010, 05:27 PM
Checkbox Values - by El Forum - 09-28-2010, 09:22 PM
Checkbox Values - by El Forum - 09-28-2010, 09:33 PM
Checkbox Values - by El Forum - 09-28-2010, 09:38 PM
Checkbox Values - by El Forum - 09-28-2010, 09:54 PM
Checkbox Values - by El Forum - 09-28-2010, 10:06 PM
Checkbox Values - by El Forum - 09-28-2010, 10:14 PM
Checkbox Values - by El Forum - 09-28-2010, 10:21 PM
Checkbox Values - by El Forum - 09-29-2010, 02:06 AM
Checkbox Values - by El Forum - 09-29-2010, 07:40 AM
Checkbox Values - by El Forum - 10-02-2010, 03:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB