Skip to main content
Inspiring
November 20, 2009
Question

How to pass form value through URL?

  • November 20, 2009
  • 2 replies
  • 1924 views

I have a page set up so that pressing the submit on a form will execute a certain page. For certain reasons I also have a URL HREF link that performs a different function. I need to get the value of a radio button group (all with the same name) and pass that value through the URL if it is pressed. So if someone clicks on the second radio button in the list which has a value of 2, I need to somehow set that to a variable to pass through a URL link. Each time the user changes the radio button I need to dynamically change the variable too.

Is there any way to do this?

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    November 20, 2009

    There is a method* that is beautiful in its simplicity. Set the form's method attribute to 'get'.

    <cfform action="#cgi.SCRIPT_NAME#" method="get">
    radio 1: <cfinput name="testradio" type="radio" value="1"><br>
    radio 2: <cfinput name="testradio" type="radio" value="2"><br>
    radio 3: <cfinput name="testradio" type="radio" value="3"><br><br>
    <cfinput type="submit" value="send" name="sbmt">
    </cfform>

    * pun intended, of course!

    Inspiring
    November 20, 2009

    Put the link inside div tags.  Then you can change the content with javascript.

    siriivenAuthor
    Inspiring
    November 20, 2009

    Do you have any brief examples?

    Inspiring
    November 20, 2009

    You could even do it using hidden form fields that post to the next step.