Radio Button - Redirect to another PHP page

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jkpalmer52
Forum Newbie
Posts: 4
Joined: Tue Nov 18, 2003 2:23 pm

Radio Button - Redirect to another PHP page

Post 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
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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"
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
Post Reply