The below examples provides you information of how to read the values from the select tag
<html>
<head>
<script language="JavaScript">
<!--//
function Message(form)
{
if (form.MySelect.options[form.MySelect.selectedIndex].value=='none')
//This is the basic code to select what to do depending on the option.
{
}// We do nothing if the first selection is chosen.
else
if (form.MySelect.options[form.MySelect.options.selectedIndex].value=='welcome')
{
alert('Welcome to javascript solutions');
}
else
if (form.MySelect.options[form.MySelect.options.selectedIndex].value=='hello')
{
alert('Hello, how are you!');
}
}
//-->
</script>
<title>Select Boxes</title>
</head>
<body>
<form>
<p><select name="MySelect" size="1">
<option selected value="none">Clicke to test</option>
<option value="welcome">Welcome to javascript</option>
<option value="hello">hello world</option>
</select><input type="button" value="clickme >>>" name="B1"
onClick="Message(this.form)"></p>
</form>
</body>
</html>
No comments:
Post a Comment