html - Javascript for loop in a select box -


i have webpage form contains input fields , 1 of these listbox. inside listbox have add (in crescent order) numbers go 40000 99999 , increase 1000 every time.

example: 40000 - 41000 - 42000 - 43000 ... 97000 - 98000 - 99000 - 99999

i wrote javascript function it's not working. here can see html code:

<fieldset style="width:500px;"> <legend><font color="#d8d8d8"><b>required fields</b></font></legend> <font color="#ffffff"><b>player's name</b>:</font> <input type="text" name="nome" /> <font color="#ffffff"><b>vrs</b>:</font> <select name="cognome"> </select> <br /> </fieldset> 

here there's javascript function

<script> var i=40000  for(i;i<42000;i=i+1000) {var select = document.getelementbyid("cognome"); select.options[select.options.length] = new option(i, i)} } </script> 

my problem data appear on listbox. have suggestions?

you're using getelementbyid need id:

<select id="cognome" name="cognome"> 

also syntax error parentheses need match :)


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -