...

View Full Version : dropdown menu selected



kiwis
11-03-2012, 09:06 PM
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?

optimizer123
11-03-2012, 09:25 PM
Something like this you mean?


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

kiwis
11-03-2012, 09:28 PM
okay i need to do it on the button click as i said for other reasons i've not gone into.

optimizer123
11-03-2012, 09:30 PM
You're confusing.

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

kiwis
11-03-2012, 09:33 PM
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.

Philip M
11-03-2012, 10:38 PM
<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

kiwis
11-04-2012, 12:17 AM
as iv'e said i want to do this on the forum submit



var val = document.getElementById("MyOption").value;
alert(val);


this does nothing.

jmrker
11-04-2012, 03:28 PM
as iv'e said i want to do this on the forum submit



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?
:confused:

Can you show some of your code that is not operating to your satisfaction?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum