I was wondering if anyone can tell me where I have gone wrong with the following code, the answer should be England, and if you select it, it should say 'you selected England correct!' however it always displays the message which its only supposed to display if you get it wrong.
<script type="text/javascript">
<!--
function checkAnswer ()
{
var oSelCountry = document.getElementById("country");
var index = oSelCountry.selectedIndex;
if (oSelCountry == "England")
{
alert("You selected" + oSelCountry.options[index].text + " correct!");
}
else
{
alert("You selected" + oSelCountry.options[index].text + " wrong!");
}
}
//-->
</script>
</head>
<body>
<p>what country borders Scotland?</p>
<select name="country" id="country">
<option >Ireland</option>
<option >Wales</option>
<option >England</option>
<option >don't know</option>
</select>
<input type="button" value="send" onclick="checkAnswer()">
Any help appreciated.
<script type="text/javascript">
<!--
function checkAnswer ()
{
var oSelCountry = document.getElementById("country");
var index = oSelCountry.selectedIndex;
if (oSelCountry == "England")
{
alert("You selected" + oSelCountry.options[index].text + " correct!");
}
else
{
alert("You selected" + oSelCountry.options[index].text + " wrong!");
}
}
//-->
</script>
</head>
<body>
<p>what country borders Scotland?</p>
<select name="country" id="country">
<option >Ireland</option>
<option >Wales</option>
<option >England</option>
<option >don't know</option>
</select>
<input type="button" value="send" onclick="checkAnswer()">
Any help appreciated.