Tuesday, 13 August 2013

How to make user to choose an option of dropdown box?

How to make user to choose an option of dropdown box?

I am using the following answer to implement a required dropdown box. The
only difference is that the code of dropdown box in my application is in a
new page which will be popped up.
The problem is that once user select any option including the one with
none value, the form gets submitted!
Page 1
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate
/1.9/jquery.validate.js"
</script>
<script type="text/javascript">
$("#everything").validate({
messages: {
dd1: {
required: "Please select an option from the list, if
none are appropriate please select 'Other'"
}
}
});
function popup(){
document.getElementById("mydropbox").style.display = "Block";
>> send request to server to show the Page 2 in body of
mydropbox <<
return false;
}
</script>
</head>
<body>
<a href="" OnClick="return popup()">popup</a>
<div id="mydropbox"></div>
...
</body>
</html>
page 2
<html>
<body>
<form id="everything">
<label for="dd1">Select the best option</label><br/>
<select name="dd1" id="dd1" class="required">
<option value="">None</option>
<option value="o1">option 1</option>
<option value="o2">option 2</option>
<option value="o3">option 3</option>
</select>
<br/><br/>
<input type="submit" />
</form>
</body>
</html>

No comments:

Post a Comment