Javascript + IE + I WANT TO SHOOT MYSELF

Suspended
Joined
26 Jul 2003
Posts
6,348
Location
Surrey
Now all I want is for the following to work:

Code:
function enableField()
{
document.form1.bt_slot.disabled=false;
document.form1.bt_day.disabled=false;
document.form1.bt_month.disabled=false;
document.form1.bt_year.disabled=false;
}
function disableField()
{
document.form1.bt_slot.disabled=true;
document.form1.bt_day.disabled=true;
document.form1.bt_month.disabled=true;
document.form1.bt_year.disabled=true;
}

Code:
<select name="status" id="select2">
            <option selected="'selected"><? echo $row['status'] ?></option>
            <option disabled="true">---------</option>
            <option onclick="disableField()">foo</option>
            <option onclick="disableField()">bar</option>
            <option onclick="disableField()">hum</option>
            <option onclick="enableField()">bug</option>
            <option onclick="disableField()">ie</option>
            <option onclick="disableField()">turd</option>
</select>

works perfectly in any browser but IE :( so I am looking for alternative ideas. As the "onclick" in a "<option" doesnt appear to be supported in IE.
 
Suspended
OP
Joined
26 Jul 2003
Posts
6,348
Location
Surrey
|Ric| said:
The normal property is enabled isnt it? Have you tried making it .enabled=true and .enabled=false ?

The problem isnt that, the problem is that IE doesnt recognise the onclick used in a select option :(

Everthing I have read always used the disabled="true", however the opposite might work.
 

Nim

Nim

Associate
Joined
17 Oct 2002
Posts
1,450
Location
Twickenham
<option> tags don't have the same functionality as most things. The only events they support (in IE, anyway), are onclosecapture(), onpropertychange(), onreadystatechange(), and onselectstart(). None of these will do what you want. The best way to sort it out is going to be running the function from the <select>, instead.

Use something like
Code:
<select onchange="someFunction(this.options[selectedIndex].value);" name="status" id="select2">
<option...
...
</select>

someFunction() will have either an if() or a switch(), which will do the appropriate gubbins to your other controls.
 
Suspended
OP
Joined
26 Jul 2003
Posts
6,348
Location
Surrey
Nim said:
<option> tags don't have the same functionality as most things. The only events they support (in IE, anyway), are onclosecapture(), onpropertychange(), onreadystatechange(), and onselectstart(). None of these will do what you want. The best way to sort it out is going to be running the function from the <select>, instead.

Use something like
Code:
<select onchange="someFunction(this.options[selectedIndex].value);" name="status" id="select2">
<option...
...
</select>

someFunction() will have either an if() or a switch(), which will do the appropriate gubbins to your other controls.

Yea thats the only way I think, I was hoping someone knew some secret IE magic along the lines of "just use onselect() instead!"... but alas... no MS IE is just pap :p
 
Back
Top Bottom