Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    dropdown menu selected

    I have a listbox with items in it, on my button click i want to send an alert message with the value of the selected item in my listbox.

    how can i do this?

  • #2
    New Coder
    Join Date
    Oct 2012
    Location
    Basement
    Posts
    88
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Something like this you mean?

    Code:
    <input type="button" value="texthere" onclick= "alert('msghere');">

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts
    okay i need to do it on the button click as i said for other reasons i've not gone into.

  • #4
    New Coder
    Join Date
    Oct 2012
    Location
    Basement
    Posts
    88
    Thanks
    9
    Thanked 0 Times in 0 Posts
    You're confusing.

    When you click on a button you want an alert message popping up correct?

  • #5
    New Coder
    Join Date
    Mar 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I want to do other validation later, for now i want to get the value of a listmenu/combo box whatever you call them in HTML on a form submit and put it in an alert.

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,917
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Code:
    <select id = "myselect" onchange = "getValue()">
    
    <option value = "0">Select A Fruit &nbsp &nbsp &nbsp &nbsp</option>
    <option value="Apple">Apple</option>
    <option value="Orange">Orange</option>
    <option value="Mango">Mango</option>
    <option value="Pear">Pear</option>
    <option value="Banana">Banana</option>
    <option value="Strawberry">Strawberry</option>
    <option value="Watermelon">Watermelon</option>
    <option value="Peach">Peach</option>
    </select>
    
    
    <script type = "text/javascript">
    
    function getValue() {
    var val = document.getElementById("myselect").value;
    if (val !=0) {
    alert (val);
    }
    }
    
    </script>
    @optimizer123 - You seem to be getting into the habit of making unhelpful replies to other questioners. In future please be sure that you have engaged brain before operating mouth.

    Kiwis said "I have a listbox with items in it, on my button click i want to send an alert message with the value of the selected item in my listbox."


    Where quality is the thing sought after, the thing of supreme quality is cheap, whatever the price one has to pay for it.
    --William James

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    New Coder
    Join Date
    Mar 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts
    as iv'e said i want to do this on the forum submit

    Code:
    	var val = document.getElementById("MyOption").value; 
    	alert(val);
    this does nothing.

  • #8
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,075
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Question

    Quote Originally Posted by kiwis View Post
    as iv'e said i want to do this on the forum submit

    Code:
    	var val = document.getElementById("MyOption").value; 
    	alert(val);
    this does nothing.
    You seem to be changing requirements every other post.
    Each response has provided an answer.
    What exactly do you wish to accomplish?


    Can you show some of your code that is not operating to your satisfaction?
    Last edited by jmrker; 11-04-2012 at 03:31 PM.


  •  

    Posting Permissions

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