Forums

Validate the choice from radio group?

d3vilr3d 04 Jun, 2008
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!
GreyHead 04 Jun, 2008
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:
<?php
if ( $_POST['checkbox_name'] == 'Option_2' {
  mosRedirect( "http://. . ." );
}
?>
Bob
d3vilr3d 05 Jun, 2008
thanks bob!

you are awesome!
d3vilr3d 06 Jun, 2008
Another question regarding this similar functionality. Is it possible to alter the email subject based on the radio group selection by user?
GreyHead 06 Jun, 2008
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
This topic is locked and no more replies can be posted.