javascript - basic JS - innerHTML only working inline -


i'm new javascript , i've searched site , other hours solution, can't work. i'm making basic mistake here.

if call innerhtml inline works perfectly:

<select id="myselect" onchange="this.innerhtml = '<option value="1">1</option><option value="100">100</option>'"></select> 

but if try call external javascript file or head doesn't work:

<script type="text/javascript"> function addsomeoptions(obj) {     obj.innerhtml = '<option value="1">1</option><option value="100">100</option>' } </script>  <select id="myselect" onchange="addsomeoptions(this)"></select> 

i add javascript in external file rather inline, since there may hundreds of options. realise there js functions adding option tags, because of way options generated, think preferable in case use innerhtml function.

you can try following code in html page,

    <script type="text/javascript">     function addsomeoptions(obj) {         obj.innerhtml = '<option value="1">1</option><option value="100">100</option>'     }     </script>     <select id="myselect" onchange="addsomeoptions(this)">           <option>testfirstvalue</option>           <option>testsecondvalue</option>     </select> 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -