Skip to main content
Inspiring
September 8, 2006
Question

Dynamic dropdown based on user selection of another dropdown on the same page

  • September 8, 2006
  • 1 reply
  • 248 views
hi all, ok, I have a table which contains use data, a name, and a userID. for the example lets say "Simon Bullen" and my userID is "999".
on a form I have, there is a dropdown box, which is dynamic from this table, and allows me to select Simon Bullen, however, I have a hidden field on the form, which when the user selects "simon bullen" the hidden field populates with the appropiate U number from the same table.... no i thought this would do it:

<cfquery name="userNumber" datasource="userList">
SELECT userNumber FROM dbo.Users WHERE Name =
<cfqueryparam value="#form.Name#">
</cfquery>

and then my dynamic form field (hidden) would reference to this query....

but it doens't work, could somebody please enlighten me? I'm hoping its something silly

Thanks in advance
    This topic has been closed for replies.

    1 reply

    Participant
    September 8, 2006
    You could make the value of the option the UserID and the option display the name.

    If that isn't what you need, I think you'll need some javascript to populate your hidden field based on what is chosen in the select.

    I think you can modify this:

    http://www.javascriptkit.com/javatutors/selectcontent2.shtml

    ...to populate your hidden field instead of a new select list.

    If there's a way to do that without JS I'm not aware of it.

    A third possibility: look up the UserID (based on the name chosen) after the form is submitted then do with it whatever you need to.