473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

not checked checkboxes input are not sent by the browser

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
3 8150
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
> 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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pete | last post by:
There is a Summary/Example further down... On page one of my site I have a form with some checkboxes and detailed descriptions. When the form is submitted (to page two), the values of the...
4
by: Piotr | last post by:
how can I read (in alert for example) array index number of checked checkbox? I have: <input type="checkbox" id="id_number" name="check" value="1" onclick="show()"/> <input type="checkbox"...
4
by: RodBillett | last post by:
I have a situation where I have 3 checkboxes - and at least 1 needs to be selected at all times... I have implemented the code that allows this behavior to happen, BUT Viewstate gets all messed...
4
by: moondaddy | last post by:
There are different times when I will have a group of checkboxes and need to force only one to be checked at a time. I would also like to do this client side and not require a postback. These...
5
by: ameshkin | last post by:
What I want to do is very simple, but I'm pretty new at PHP and its a little hard for me. I have one page, where there are a rows of checkboxes. A button selects all checkboxes, and then...
4
by: haresh.amis | last post by:
hello to all, I m using .net 2.0 and i face a problem that is as under Well I have a checkboxlist which i bound in .cs page now I want to count that how many checkboxes ate checked ( In...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
2
by: dkultasev | last post by:
Hello, I have small script which generates some listboxes. Their names are listXX (list01, list02, list03....). How to check if there are checked or not ? If I have 1 listbox and have it's name I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.