Click to See Complete Forum and Search --> : How to create Form to go to different forms


tekboy
10-10-2005, 11:04 AM
How to create Form to go to different forms
Form1 has 3 checkboxes if depend on what is checked will go to that form
checkbox A
checkbox B
checkbox C

if checkbox A is checked will go to form for A
if checkbox B is checked will go to form for B
if checkbox C is checked will go to form for C

if A & B checked will go to a form contains both A&B
if A & C checked will go to a form contains both A&C
if B & C checked will go to a form contains both B&C
if A & B & C checked will go to a form contains both A&B&C

thanks

LimpBagel
10-10-2005, 11:12 AM
initially submit the form to itself.

Then decide what form you want to go to based on what is set in $_POST.

Then use post in the form's action.

tekboy
10-10-2005, 11:14 AM
what do you mean im not sure...can you give me some example

LimpBagel
10-10-2005, 11:33 AM
if(!(isset($_POST['boxA']) || isset($_POST['boxB']) || isset($_POST['boxC'])) {
$action = 'thisFile.php';
} else {
$action = 'script.php';
}


//form

<form name="nothing" action="<?=$action;?>">


Then just throw in some javascript to call document.nothing.submit() if $action != thisFile.php

There are probably better ways to do it but that is the first I thought of.

Make sure you also check the boxes based on what is in POST.

tekboy
10-10-2005, 01:54 PM
i got

Parse error: syntax error, unexpected '{' in D:\Inetpub\wwwroot\test\q1.php on line 1

LimpBagel
10-10-2005, 02:13 PM
Most likely because I missed a trailing ). That is just to give you the idea anyway, pasting it in won't help too much.