Skip to main content
Participant
April 27, 2006
Question

Pass form value to URL

  • April 27, 2006
  • 3 replies
  • 525 views
I want the country selected using this form also to show up in the URL on the click-through page so that visitors can copy the URL and share it with others. I assume that I need to extend the url in the form action, but am not sure of the syntax. Any help is very welcome.
<form action="ngo_details.cfm" method="post">
<select name="country">
<option value="Select a country">Select a country</option>
<cfoutput query="country">
<option value="#country.memberCountry#">#country.memberCountry#</option>
</cfoutput>
</select>
<input type="submit" name="Submit" value="Go" />
</form>
    This topic has been closed for replies.

    3 replies

    Inspiring
    April 27, 2006
    One way to do it is to use method="get" instead of method="post".

    Having said that, if any of your countries have spaces in the names, it might cause problems.

    If you get UpstateRoadie's approach working, (a possible reason it crashed for you is that you need cfoutput tags), use the urlencodedformat function.
    Participating Frequently
    April 27, 2006
    You could have the form post to a secondary page, and use a cflocation tag on the secondary page to add the form varible to the url...for example:


    <cflocation addtoken="no" url="myresultspage.cfm?country=#form.country#">
    gefjoAuthor
    Participant
    April 27, 2006
    Thanks for the suggestion. It threw an error, telling me that the form field name was misspelled, which it isn't. I'll read up on cflocation and see if I can't get to go.
    Participating Frequently
    April 27, 2006
    There's a few ways to do this. Are you displaying the results of "ngo_details.cfm" directly or is that page redirecting to another page?
    gefjoAuthor
    Participant
    April 27, 2006
    Matt,
    Probably the best thing is to have a quick look: http://thegef.org/Partners/ngo/ngo_country_selection.cfm