option.selected can't be changed

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I encoutered a problem which almost drove me crazy, but let me skip my
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:
<form >
<select >
<option id="op" value="initialValue" selected="false">op</option>

function fun(){
var bool=(1==2);
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.
    thank you!

Re: option.selected can't be changed

Quoted text here. Click to load it

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".

Quoted text here. Click to load it

Now try running your script.

Adrienne Boswell
Please respond to the group so others can share

Site Timeline