Announcement

Collapse
No announcement yet.

js - IE11 only: Unable to get property 'options' of undefined or null reference

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • js - IE11 only: Unable to get property 'options' of undefined or null reference

    New to this forum and hopefully someone can help. The following script works in all other browsers, except ie11, which is the one it has to work in.
    Referencing this line:
    Code:
     var lable=event.target.options[event.target.selectedIndex].parentNode.label;
    vanilla js only, no jquery. Here is sample html and javascript. If anyone can help so it works in ie11, would appreciate
    Code:
      
     function run(event) { console.log(document.getElementById("user").label); var lable=event.target.options[event.target.selectedIndex].parentNode.label;     if(lable == 'user'){       document.getElementById("copy").value = "user";     } else if (lable == 'warehouse') {     	document.getElementById("copy").value = "warehouse";     } else if (lable == 'dollhouse') {     	document.getElementById("copy").value = "dollhouse";     } }
    [HTML] <form> <select name="sel" id="sel" onchange="run(event)"> <option selected disabled>Wybierz...</option> <optgroup id="user" value="user" label="user"> <option value="1">michal</option> <option value="2">mateusz</option> </optgroup> <optgroup id="warehouse" value="warehouse" label="warehouse"> <option value="1">kosz</option> <option value="2">zaginione</option> </optgroup> <optgroup id="dollhouse" value="dollhouse" label="dollhouse"> <option value="1">muiy</option> <option value="2">goey</option> </optgroup> </select> </form> <input type="text" name="copy" id="copy"> [/HTML]

  • #2
    Moved to more appropriate forum
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment

    Working...
    X