Results 1 to 3 of 3

Thread: [RESOLVED] Javascript get selected value

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    233

    Resolved [RESOLVED] Javascript get selected value

    hi, how to create a validation if a choice has been made by the user? thank you for any ideas..

    Code:
    <body>
    <form name="form1">
    
    <select name="menu1">
    <option>Select Item
    <option>test1 
    <option>test2
    <option>test3
    </select>
    
    </form>
    <input type="submit" name="send" value="Send Details"></p>
    </body>
    The taller the bamboo grows the lower it bends...

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Javascript get selected value

    Your submit button needs to be inside your form.

    Code:
    <body>
    <form name="form1">
    
    <select name="menu1">
    <option value="">Select Item
    <option>test1 
    <option>test2
    <option>test3
    </select>
    
    <input type="submit" name="send" value="Send Details">
    </form>
    </body>
    
    <script type="text/Javascript">
    <!--
    
    document.form1.onsubmit = function(){
      if(this.menu1.value == ""){
        alert("it's blank.");
        return false;
      }
      return true;
    }
    
    //-->
    </script>

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    233

    Re: Javascript get selected value

    thanks SambaNeko
    The taller the bamboo grows the lower it bends...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width