Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Put the link inside div tags. Then you can change the content with javascript.
Copy link to clipboard
Copied
Do you have any brief examples?
Copy link to clipboard
Copied
You could even do it using hidden form fields that post to the next step.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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!