Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- option.selected can't be changed
July 16, 2005, 10:43 am
rate this thread
personal problem, and show you this really strange problem.
msdn.microsoft.com told me that selected is a boolean attribute
with "false" as its default value.However, unfortunately, I found that
not only "selected" was "true" when I assigned "false" to it, but also
remained "true" all the time even when I tried to change it to "false".
here go the codes:
<option id="op" value="initialValue" selected="false">op</option>
alert("op.selected is "+op.selected + " op.value is "+op.value);
I have tried to find some explanation by google but without any
result, I appriciate it if you tell me why or where i am wrong.
Re: option.selected can't be changed
Here's your problem
<option id="op" value="initialValue" selected>op</option>
If you are using XHTML where all attributes must have values, then you
would use selected="selected".
For checkboxes, it's checked, or checked="checked".
Now try running your script.
Please respond to the group so others can share