1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Javascript + IE + I WANT TO SHOOT MYSELF

Discussion in 'HTML, Graphics & Programming' started by Noxis, 25 Jan 2006.

  1. Noxis

    Banned

    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.
     
  2. |Ric|

    Hitman

    Joined: 28 Jun 2005

    Posts: 895

    The normal property is enabled isnt it? Have you tried making it .enabled=true and .enabled=false ?
     
  3. Noxis

    Banned

    Joined: 26 Jul 2003

    Posts: 6,348

    Location: Surrey

    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.
     
  4. Nim

    Wise Guy

    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.
     
  5. Noxis

    Banned

    Joined: 26 Jul 2003

    Posts: 6,348

    Location: Surrey

    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