"Richard Haygreen" <rj***@kent.ac.uk> wrote in message
news:cj**********@athena.ukc.ac.uk...
I have an HTML form which includes a combo box with 4 options, which is
used to select a method of contact (phone, email etc...). If the user selects
an invalid option (for example, they have selected phone, but have not
supplied a phone number) an alert box pops up. How do I reset the combo box so it
displays the first option in the combo box (which is the default)??
Many thanks in advance.
document.{form_name}.{select_name}.selectedIndex = -1;
For example, watch for word-wrap.
<html>
<head>
<title>selreset.htm</title>
<script type="text/javascript">
function selected(that) {
var form1 = document.form1;
// substitute your validation below.
if (1==1) {
alert("Invalid selection!");
that.selectedIndex = -1;
}
}
</script>
</head>
<body>
<form name="form1">
<select name="ContactMethod"
onchange="selected(this)">
<option>
<option>Phone
<option>Email
<option>Pager
<option>Other
</select>
</form>
</body>
</html>