strange behavior with disabled select box
Is it normal for a disabled select box to not pass its value through to $_POST?
I have two selects on my page.
The first select box if a certain value is selected it sets the value of selectbox2 and disables it but that selectbox2 then has no data when I check the $_post array when I want it to pass the data I just set it too?
Any ideas, or is there a better way of doing?
It is not only normal, is what the w3c specification says it should do. You can set it to "readonly" instead. (You may have to do a little CSS fiddling if you want it to look the same as disabled.)
Originally Posted by k0r54
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I tend to add a hidden field with a value of 0 just before the checkbox (and named the same as the checkbox) when I want a value even if the checkbox is empty or disabled:
<input type="hidden" value="0" name="foo" />
<input type="checkbox" value="1" name="foo" />
Thanks for the input, I did notice that select does not actually have a readonly so to get around it I put it all into a span and i get the JS to hide the div but leave the select box enabled with the value i tell it.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)