Link to home
Start Free TrialLog in
Avatar of CementTruck
CementTruck

asked on

Need help using radio buttons to direct the flow of CF statements

Hello Experts,

I have a page that asks users to choose between 2 options (fork-in-the-road). Once the user clicks in the radio button of choice I want a specific <CFIF statement to start, thereby displaying the rest of the options on the page pertinent to the choice. At first I thought doing a CFIF, then CFELSE, but I thought I better ask you guys for a better solution first.

Thanks,

Avatar of mrichmon
mrichmon

Nope can't do that uness the page submits in between - not user friendly...

Instead you need javascript to determine which section to show.

Let me know if you are interested in that path...
Avatar of CementTruck

ASKER

mrichmon,

I am interested. Please elaborate.

"Nope can't do that uness the page submits in between - not user friendly..." Can you expound on this as well? At what point would you want it to resubmit?
mrichmon,

What about 2 select buttons, or links, instead of radio buttons, would that work?
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Easiest solution here is probably to use <div> layers and default them to style="display:none", this will hide them by default when the page loads. Make sure your div tags have an ID <div id="choice1" style="display:none; overflow:auto">content here</div>

Use an onClick on each radio button to pass the the ID of your div layer "choice1" or "choice2" into the javascript below which will toggle the visibility of the div layers.

onclick="ShowOrHide('choice1') will toggle the visibility of the div layer with ID choice1

function divToggle(D) {
var thediv = document.getElementById(D) ;
                  if(thediv.style.display == 'none') {
                        thediv.style.display = '';
                  } else {
                        thediv.style.display = 'none';
                  }
}
try use cflocation
<cfif form.page eq "a">
     <cflocation url="/A.html" addtoken="no">      
<cfelseif form.page eq "b">
     <cflocation url="/B.html" addtoken="no">
<cfelse>
     <cflocation url="/c.html" addtoken="no">
</cfif>
or even you can use cfinclude to include the whole page if they are cfm page.

in the form
<INPUT TYPE="radio" name="page " value="a">Page A
<INPUT TYPE="radio" name="page " value="b">Page B
<INPUT TYPE="radio" name="page " value="c">Page C
Thank you all for your subissions. Mrichmon's answer suited my application best.