By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

not checked checkboxes input are not sent by the browser

P: n/a
Hello,

I discovered that in a form with checkboxes input, if the checkboxe is
not checked, not value is sent in my request by the browser (at least
IE, I think it is ok in NS).
But I my application I need to get the input even if it is not checked
(my form is dynamic and I distinguish the cases: input exists and is
cheched / input exists ans is not checked / input doesn't exists)
I know I could use another input such as textfield, but I wonder if
there is another solution that would allow me to keep the checkboxe
and send it even if not checked.
Thanks for any help!
G.
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
lehmann wrote:
Hello,

I discovered that in a form with checkboxes input, if the checkboxe is
not checked, not value is sent in my request by the browser (at least
IE, I think it is ok in NS).
Its "OK" in all browsers.

Unchecked checkboxes are not submitted, that is how it is supposed to work.
But I my application I need to get the input even if it is not checked
Then test for the _existance_ of the variable rather then its value.
(my form is dynamic and I distinguish the cases: input exists and is
cheched / input exists ans is not checked / input doesn't exists)


Then you should include an input that specifies which checkboxes exist.

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #2

P: n/a
> But I my application I need to get the input even if it is not checked
(my form is dynamic and I distinguish the cases: input exists and is
cheched / input exists ans is not checked / input doesn't exists)
I know I could use another input such as textfield, but I wonder if
there is another solution that would allow me to keep the checkboxe
and send it even if not checked.


You say it's dynamic, so just in case it's anything like mine - I'm doing
something with PHP & MySQL, this is what I did. I put a hidden field in the
form and link it to the checkbox, like this (a checkbox to click whether or
not a user's address should be visible on my site):

<input name="showaddressControl" type="checkbox" id="showaddressControl"
value="showaddressControl" onClick="this.form.showaddress.value =
((this.checked)?1:0)">
<input name="showaddress" type="hidden" value=""
onChange="this.form.showaddressControl.checked =
((this.value==1)?true:false)">

The first input is the checkbox, and when it's clicked, it sets the hidden
value to 1 (MySQL for TRUE) if the checkbox is checked, and 0 (FALSE) if
it's not.

The second input is the actual value that I get and put from/to the
database. The reason I have an onchange handler in it is that I dynamically
fill it with data on different persons, so whenever its value changes, the
checkbox is changed too to reflect the new value. You could give it a
default value of "null" or "not set" or something to show when 'input
doesn't exist').

Hope this has something to do with what you're doing and that it will help
;)

Cheers,
Daniel
--
There are 10 kinds of people: Those who know binary and those who don't.
Jul 20 '05 #3

P: n/a


Your solution seems perfect for me!
Thanks a lot!!! :-)
G

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.