How to access the javascript variable inside html tags -


i wanted added javascript variable inside html code. here code:

 <select id="currentrun" name="currentrun" >         <option value=""><script>selectedrun</script></option>  </select> 

and js function

 var currentrun="";  var selectedrun="";   function setcurrentrun()   {      currentrun = document.getelementbyid("runlist");     selectedrun = currentrun.options[currentrun.selectedindex].value;           } 

but doesn't work.

can me this.

thanks in advance.

you don't have run script that.

the value of currentrun can retrieved as:

document.getelementbyid('currentrun').value 

and completeness, if want trigger javascript function call each time selection modified, this:

<select onchange="my_function();">   <option>...</option> </select> 

Comments