Skip to main content
Participant
November 8, 2021
Question

Passing dropdown form into variable

  • November 8, 2021
  • 1 reply
  • 137 views

I have a dropdown form from which the user selects from a list of query populated options (code blow). This query is in the mycars.cfm page whitch is within my views folder. 

 

<h3>Car Names</h3>
<cfquery name="carbrands" > 
SELECT *
FROM carcompany
WHERE cartype_id = 6
</cfquery>
<cfform name="mycars" action="?????.cfm"> 

<cfselect name="carbrandsearch" 
query="carbrands" 
value="car_name" 
display="car_name">
</cfselect> 

 

I am looking to pass the users selected option (let say Mazda) into a variable so that I can pass that variable into other queries down the page.

 

I am not sure how to do this. I have tried to tie the submit button to the active page itself but continously get this error - File not found: /views/mycars.cfm. However this is the very page that my dropdown is on so I do not understand why it is giving me this error. 

 

I've also heard mention of the bind function but I am not sure how to use it/if it is appropriate for this case.

 

I want to be able to pass the car name (Mazda for example) that the user selects into a variable so that I can put that variable into a query where I could idtenify all people who drive the specific car type that the user selected from the dropdown . 

 

What would be the best way to go about doing this?

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    November 8, 2021

    I provided the full code of an example just over a week ago. 🙂

    https://community.adobe.com/t5/coldfusion-discussions/cfselect-onchange/m-p/12459870

    Participant
    November 9, 2021

    Thanks for the example. Howwver, I have decided to go the JQuery/Ajax way. Do you happen to have any pointers on how to best convert the CF form to Javascript? 

    BKBK
    Community Expert
    Community Expert
    November 10, 2021

    Sure thing. Take a look at ColdFusion UI - the right way. I suppose the one you want is "cfselect-chained".