Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using onChange with a CFquery

Status
Not open for further replies.

DrumAt5280

Technical User
Sep 8, 2003
194
US
The following Coldfusion code dynamically generates a list of suburbs in a pulldown menu.

I would like to use onChange="gotoURL();" so when a user selects a suburb from the menu it will take him to the correct page without a submit button. I know how to do this with plain HTML but not in Coldfusion.

CODE
<cfform id="forma" method="post" action="" name="forma">
<CFSELECT NAME="csFk"
QUERY="GetSuburb"
VALUE="suburbId"
DISPLAY="suburb" >
<OPTION value="0" selected>-- all location --</option>
</CFSELECT>
</CFFORM>

Any ideas? (I had posted this in the JavaScript forum but was asked to move it here)
 
<script language="JavaScript" type="text/JavaScript">
<!--
function changeLoc(targ,selObj,restore){ eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<form name="form1" method="post" action="">
<select name="menu1" onChange="changeLoc('parent',this,0)">
<option value=" <option value=" </select>
</form>
</body>
</html>

 
I know how to do this with plain HTML but not in Coldfusion.
This is one of the (many) nasty little reasons I don't like cfform. Up until now, you had to use html, there wasn't a way to do this in CF. But, if you're using CF 7, the cfselect tag now supports an onChange event. I don't believe previous versions had this functionality, but I don't use cfform so I can't be sure.

You'd probably be better off using html, though.


Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top