I am trying to make a picklist automatically pick a user selected option, without hitting a "go" or submit button.
Can this be done with PHP, if not, I hear it can with Java... How do you do this, please help...
help making picklist auto pick ?? Please
Moderator: General Moderators
Elmseeker is right - Javascript is the way to do this. The way I do it is to utilize the "onChange" method of the picklist (a "select" object in HTML forms parlance) to call a Javascript function that will do what I want right then. The example below loads a new page based on what the user selects from the list.
Code: Select all
<html>
<head>
<script language="Javascript">
<!--
function gotoPage() {
if (document.selectpage.pagelist.value != "") {
if (top.main && top.main.document) {
top.main.document.location.href =
document.selectpage.pagelist.value + ".html" ;
}
else {
document.location.href =
document.selectpage.pagelist.value + ".html" ;
}
}
}
// -->
</script>
</head>
<body>
<form name="selectpage">
<select name="pagelist" onChange="gotoPage();">
<option value="" disabled>Select from this list</option>
<option value="page1">First Page</option>
<option value="page2">Second Page</option>
<option value="page3">Third Page</option>
</select>
</form>
</body>
</html>