I'm trying to output the selected value form a select box and compare it, see code below. If someone selects "Test1", I want the alert box "yes", for every other selection, "no". I'm sure this is simple stuff, but I'm stumped! Can anyone help me?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/javascript">
function showhide() {
var s = document.getElementById("t");
if(s.options[s.selectedIndex].text = "Test1") {
alert("yes");
} else {
alert ("no");
}
}
</script>
</head>
<body>
<select name="ttype" onchange="showhide()" id="t">
<option value="Test1">Test1</option>
<option value="Test2">Test2</option>
</select>
</body>
</html>