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"
        }

}


Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI