Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnSubmit in Forms to Control Action 1

Status
Not open for further replies.

MinalMoe

IS-IT--Management
Mar 25, 2004
62
GB
I'm using cfform within a MX7 environment. The form contains a RadioButton set up with 1 of 3 choices. Is there a way I can use OnSubmit to control the Action Field so that If RadioButton 1 is selected then the Action URL is Page_1 and if 2 then it goes to Page_2 etc.

If so how would it work?

Thanks for any help.
 
document.form.action.value = 'WhatYouWantItToBe.cfm';

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
Sadly Phil - that didn't work.

It has to have the choice of 3 different .cfm pages to go to. Using either onSubmit or onClick doesn't work. The only way that works is

<cfif Left(Trim(Form.ChoiceButton), 1) EQ "B"><SCRIPT language="JavaScript">window.location="1.cfm";</SCRIPT></cfif>
<cfif Left(Trim(Form.ChoiceButton), 1) EQ "F"><SCRIPT language="JavaScript">window.location="2.cfm";</SCRIPT></cfif>
<cfif Left(Trim(Form.ChoiceButton), 1) EQ "H"><SCRIPT language="JavaScript">window.location="3.cfm";</SCRIPT></cfif>

But then, I can't pass the parameters, so once again I'm stuck. Any ideas?
 
Sorry my reply was so terse.

Window.location does not transport the form field values. You have to use document.submit();

Javascript should evaluate the button, not CF. This takes place client-side in a function:
...
if (document.choicebutton.value == 'B')
{
document.form.action.value = 'WhatYouWantItToBe.cfm';
}
etc.


Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
You could just submit the form, see what value was checked, then have cf go to the appropriate page.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
The issue is that each action page must process the form field values from the original page. CFLOCATION to the other page would require that you transport the form field values using some sort of additional manipulation. Why do all this extra coding when about 12 lines of Javascript will take care of it?

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
Why worry about trying to mix CF and Javascript to do what can easily be done by CF alone? If you don't want to redirect to the appropriate page, then just use a cfinclude tag on your action page to import whatever page you need. Or, use cfif to display additional stuff on the action page depending on what button was checked. There are plenty of different ways to accomplish this, with or without Javacript. It's just a matter of personal preference.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Thanks for all the help, but the best solution was to insert onClick="document.forms['FormName'].action = '1.cfm' into each of teh RadioButtons.

Thanks for all the interest and help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top