Page 1 of 1

Radio Button - Redirect to another PHP page

Posted: Sun Nov 14, 2004 6:51 am
by jkpalmer52
Im using Dreamweaver and I'm a very NEW NEWBIE,

I'm looking for an example to make this work in Dreamweaver and PHP:

Simply put,

I have a form with five radio buttons and a submit button.
If button A is on when submit button pressed, then open form_A.php ELSE
If button B is on when submit button pressed, then open form_B.php ELSE
If button C is on when submit button pressed, then open form_C.php ELSE
If button D is on when submit button pressed, then open form_D.php ELSE
If button E is on when submit button pressed, then open form_E.php

Can't seem to get this to work. Example would be greatly appreciated.
TIA
-jP

Posted: Sun Nov 14, 2004 6:54 am
by patrikG
edit: topic moved to client-side.

You may want to look at HTML form action and use javascript. You can change the target of a form with javascript code like below. You will need to add and if statement for more conditions.

Code: Select all

document.yourForm.action="open_form_A.php"

Posted: Mon Nov 15, 2004 5:56 am
by anjanesh
If you want to do it in the PHP side then you can have the radios as a radio group like :
<FORM NAME=frm1 METHOD=POST ACTION="form_X.php">
<INPUT TYPE=radio NAME=rg1 VALUE="A">
<INPUT TYPE=radio NAME=rg1 VALUE="B">
<INPUT TYPE=radio NAME=rg1 VALUE="C">
<INPUT TYPE=radio NAME=rg1 VALUE="D">
<INPUT TYPE=radio NAME=rg1 VALUE="E">

Now when you click the submit button, you can get the values in form_X.php :
switch ($_POST['rg1'])
{
case "A":include_once("form_A.php");break;
case "B":include_once("form_B.php");break;
case "C":include_once("form_C.php");break;
case "D":include_once("form_D.php");break;
case "E":include_once("form_E.php");break;
}

or include_once("form_".$_POST['rg1'].".php"); if your radio values are going to be same as the php file names.