Advertisement
jiue123

getting value of select when onclick

Jul 16th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  <select style="color:#9E9E9E; border-radius:5px !important;" name="sex" id="sex">
  2.                <option value="0" disabled="disabled" selected="selected">Select Sex----</option>
  3.                <option style="color:#000" value="1">Male</option>
  4.                <option style="color:#000" value="2">Female</option>
  5.    </select>
  6.   <a href="javascript:" onclick="next()" ><button class="button1">Create Account&Couninue</button></a>
  7.   <div id="sex1" style="display:none" class="invalid">invalid entry for confirm sex</div>
  8. <script>
  9.     function next(){
  10.         var obj = document.getElementById("sex").options;
  11.         var sval = obj[obj.selectedIndex].value;
  12.         if(sval == 0){
  13.             $("#sex1").css('display', 'block');
  14.             return false;
  15.         }else{$("#sex1").css('display', 'none'); }
  16.     }
  17. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement