Validate the choice from radio group?

Shows some Tutorials

Validate the choice from radio group?

Postby d3vilr3d on Wed Jun 04, 2008 3:10 pm

HI Guys,

I am trying to figure out how to use radio group to decide which action to take after user submits the form.

I am making a material request form. if the user picks 1 of the option(by mail), no action is taken, just save their form info and send email.

if the user picks the 2nd option (download material online), then after the info is saved and emails are sent, I need to redirect them to the download link url.

Can anyone point me in the right direction on how this can be done??

Thanks!
d3vilr3d
Junior Boarder
 
Posts: 21
Joined: Fri May 09, 2008 3:28 pm

Re:Validate the choice from radio group?

Postby GreyHead on Wed Jun 04, 2008 3:23 pm

Hi d3vilr3d,

In the 'Onsubmit before' box test the value of the 'checkbox' variable. If it's Option 1 do nothing, let the email run its course. If it's Option 2 then do an immediate redirect. I don't remember which Joomla version you are using but for Joomla 1.0.x the code is something like:
Code: Select all
<?php
if ( $_POST['checkbox_name'] == 'Option_2' {
  mosRedirect( "http://. . ." );
}
?>
Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Validate the choice from radio group?

Postby d3vilr3d on Thu Jun 05, 2008 4:28 pm

thanks bob!

you are awesome!
d3vilr3d
Junior Boarder
 
Posts: 21
Joined: Fri May 09, 2008 3:28 pm

Re:Validate the choice from radio group?

Postby d3vilr3d on Fri Jun 06, 2008 3:03 pm

Another question regarding this similar functionality. Is it possible to alter the email subject based on the radio group selection by user?
d3vilr3d
Junior Boarder
 
Posts: 21
Joined: Fri May 09, 2008 3:28 pm

Re:Validate the choice from radio group?

Postby GreyHead on Fri Jun 06, 2008 4:53 pm

Hi d3vilr3d,

Yes, you can change almost anything depending on almost anything else. In this case you need to add the code to the 'OnSubmit before' box and set a new value for $rows[0]->emailsubject

Bob
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3251
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany


Return to How To

Who is online

Users browsing this forum: Alexa [Bot], MSN [Bot] and 3 guests