Reputation: 1
So I have this code below. What it invokes is a query from the database which outputs all the brands of cars I have in the database. It then displays them in a dropdown list, hence this code below.
<h2>Car brand Option</h2>
<cfform name="mycarchoice" action="mainpage.cfm">
<cfinvoke method="brandMatch" component="thecars.brand" returnvariable="getbrands">
<cfselect name="mycarchoice.getbrands"
query="getbrands"
value="brand_name"
display="brand_name">
</cfselect>
<br><input type="Submit" value="Submit" method="post">
</cfform>
I want to pass the users selected option to the mainpage.cfm so that I can do some processing on it. I have added mainpage.cfm as the action to be done when submit is pressed.
However, I don't know how to catch the value on my mainpage.cfm. What do I do/how do i start of so that I can write some code using what ever option my user selected from the code above as the input for whatever code I want to write on the mainpage.cfm.
Any examples would be ideal.
Thanks
Upvotes: 0
Views: 124
Reputation: 20804
Step 1 - This becomes simpler if you change the name of your cfselect
control so that it does not contain a period. For the sake of this answer, we'll assume that you changed this:
<cfselect name="mycarchoice.getbrands"
to this:
<cfselect name="chosenbrand"
Step 2 - on mainpage.cfm, the users selection is available as a variable in the form scope. It's name will be form.chosenbrand
. You can verify this by starting your mainpage.cfm with this code:
<cfoutput>
#form.chosenbrand#
</cfoutput>
<cfabort>
Once you know that the variable is there, you can process it as required.
Upvotes: 1