Skip to main content
Known Participant
September 16, 2009
Question

Jump Menu using CFSelect

  • September 16, 2009
  • 1 reply
  • 1007 views

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>

    This topic has been closed for replies.

    1 reply

    Inspiring
    September 16, 2009

    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

    J_TremainAuthor
    Known Participant
    September 16, 2009

    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>