Copy link to clipboard
Copied
I'm trying to create a query generated jump menu that will jump the user to a new page based on whatever option is selected from the drop down menu. I'm basically a little lost on handling the onChange action of the form. Here's the code I have so far.
<cfform action="pro/course.cfm?courseID=#rsCourses.courseID#" method="post">
<cfselect name="courselist"
size = "1"
width="150"
multiple = "No"
message = "Select a course"
query = "rsCourses"
group="courseCategory"
display ="courseName"
onChange="courselist.selectedIndex=courseID"
selected="courseID"
value = "courseID"
queryPosition = "Below"
>
<option value = "">Select a course</option>
</cfselect>
</cfform>
Copy link to clipboard
Copied
This is more of a JavaScript question than a CF question, I think: the onchange attribute is not specific to <cfselect>, it's just bubbled through to the generated <select> tag.
So just write a normal JavaScript event handler function (to do whatever), and call it from the onchange attribute. Same as any JS event.
--
Adam
Copy link to clipboard
Copied
I figured it out, you're right though. Here's what I got to work:
<cfform action="" method="get">
<cfselect name="courselist"
size = "1"
width="150"
multiple = "No"
message = "Select a course"
query = "rsCourses"
group="cat_Name"
display ="courseName"
onchange="window.location='pro/course.cfm?courseID='+this.value;"
selected="courseID"
value = "courseID"
queryPosition = "Below"
>
<option value = "">Select a course</option>
</cfselect>
</cfform>
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more