How to get option value (javascript)
        Posted  
        
            by Mahmoud
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Mahmoud
        
        
        
        Published on 2010-04-20T14:01:56Z
        Indexed on 
            2010/04/20
            14:03 UTC
        
        
        Read the original article
        Hit count: 179
        
JavaScript
|html
Below are the options that i have in my code
    <label id="subn">
      <select name="subs" id="subs">
      <option value="nothing">Choose a Subject</option>
      <option value="General Question">General Question</option>
      <option value="MemberShip Area">MemberShip Area</option>
      <option value="Others">Others</option>
      </select>
    </label>
and i want to create a javascript that well check if the user select a subject other than the first below what i tried using
if (document.getElementsByTagName('option') == "nothing"){
            document.getElementById("subn").innerHTML = "Subject is Required!";
            document.getElementById("subs").focus();
                    return false;
         }
© Stack Overflow or respective owner