Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to pass form value through URL?

Explorer ,
Nov 20, 2009 Nov 20, 2009

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?

1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 20, 2009 Nov 20, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 20, 2009 Nov 20, 2009

Do you have any brief examples?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 20, 2009 Nov 20, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 21, 2009 Nov 21, 2009

Googling "javascript change value div" will give you examples. Depending on your circumstances, you may want to avoid the innerHTML options.  They won't work on Firefox.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 23, 2009 Nov 23, 2009
LATEST

Thanks for the suggestions everyone. Here is what I have so far:

I have a cfInput that binds to the radio buttons so the value of the cfinput changes dynamically.

I have a CFDIV that binds to a separate .cfm page that passes the cfinput through as an argument.

The .cfm is very basic:

<cfoutput>
    <cfif isdefined("url.InputText") AND url.InputText NEQ "">
        <cfset FeedVar = #url.InputText#>
      
    <cfelse>
      
    </cfif>
</cfoutput>

This method appears to work and it sets the Feedvar variable to the appropriate value. However on my first page with the cfdiv tag when I try to pass the #FeedVar# variable through a URL it says it is not defined.

Any clue if I am doing something wrong passing the new variable back?

Here is the CFINPUT and CFDIV tags:

<cfinput type="text" name="update_typeURL" bind="{update_type}" bindonload="true" />
<cfdiv bind="URL:setURlVar.cfm?InputText={update_type}" ID="theDiv" bindonload="true"  />

Any ideas on how to read the newly set variable?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2009 Nov 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources