...

View Full Version : select



windowcleaner
09-19-2005, 10:14 PM
My form has some select options, is it possible to automaticly submit the page when an option has been selected ? (so that i can get rid of the submit button). It would be great if the code works on any browser.

<html>
<head>
<title>Untitled</title>
</head>
<body>
<form action="www.blablabla.com/cgi-bin/blabla.cgi">

<select name="area">
<OPTION value="None">select a City</OPTION>
<OPTION value="1">London</option>
<OPTION value="2">Paris</OPTION>
<OPTION value="3">New York</OPTION>
</select>

<input type="submit">
</form>
</body>
</html>

nikkiH
09-19-2005, 10:27 PM
Sure.

<select name="area"
onchange="if (this.selectedIndex != 0) this.form.submit();">

Oh, note that this means you're throwing accessibility out the window.

glenngv
09-20-2005, 05:38 AM
What you can do is hide the submit button onload.


<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
function init(){
document.getElementById("btnGo").style.display = "none"; //hide submit button
}
</script>
</head>
<body onload="init();">
<form action="www.blablabla.com/cgi-bin/blabla.cgi">
<select name="area" onchange="if (this.selectedIndex != 0) this.form.submit();">
<OPTION value="None">select a City</OPTION>
<OPTION value="1">London</option>
<OPTION value="2">Paris</OPTION>
<OPTION value="3">New York</OPTION>
</select>
<input type="submit" name="btnGo" id="btnGo" value="Go" />
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum