Reset combox box in html with given index


<select id="myCombo" onchange="moreOptions()">
      <option value="-1" selected="selected">Select options</option>
      <option id=" myCombo _1" value="1">One</option>
      <option id=" myCombo _2" value="2">Two</option>
      <option id=" myCombo _3" value="3">Three</option>
   </select> 


Javascript to reset onChange() method...


function moreOptions(){
var selectedOption=document.getElementById(" myCombo ").value;
if(selectedOption=="1"){
..........
}else if(selectedOption=="2"){
........
}else if(selectedOption=="3"){
.......
}else{
         document.getElementById(" myCombo ").selectedIndex="0";   //reset combox box with "Select options"
        }

}


Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine

Android: where to run keytool command in android