473,508 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Action "if x go to 1.php else go to 2.php

142 New Member
Hi,

I have to radio buttons and depending on the selection it must eighter insert step2.php or insert.php in the action part of the form.

Now it's just going to steo2.php

I also tried elseif ($rado="no") but thats giving the same problem.

Thans


[PHP]
<form id="form1" name="form1" method="post" action="<? $radio=$_POST['radio']; if ($radio="yes")
echo "step2.php";
else
echo "insert.php"; ?> ">
<p>
<label>
<input name="radio" type="radio" value="yes" />
</label>
</p>
<p>
<input name="radio" type="radio" value="no" />
</p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
[/PHP]
Mar 19 '08 #1
8 8210
ronverdonk
4,258 Recognized Expert Specialist
That is half your script, even only half your form. Where is the submit part of that and where is the script that catches the submitted form?

In order to help you you must show more code than this little piece.

Ronald
Mar 19 '08 #2
Markus
6,050 Recognized Expert Expert
Why don't you just have the url of the next page set to the value of the radio button?

[php]
<?php
$radio = @$_POST['radio']; # use @ to supress the 'undefined index' warning.
?>
[/php]
Expand|Select|Wrap|Line Numbers
  1. <form id=".." action="<?php echo $radio;?>" method="post">
  2. <input name="radio" type="radio" value="yes.php" />
  3. <input name="radio" type="radio" value="no.php" />
  4. <label>
  5. <input type="submit" name="Submit" value="Submit" />
  6. </form>
  7.  
Mar 19 '08 #3
satas
82 New Member
Hi,
I have to radio buttons and depending on the selection it must eighter insert step2.php or insert.php in the action part of the form.
Or you can use JavaScript to change action attribute without reloading page.
Mar 19 '08 #4
webandwe
142 New Member
That is half your script, even only half your form. Where is the submit part of that and where is the script that catches the submitted form?

In order to help you you must show more code than this little piece.

Ronald

Hi have a huge form. I only made this two radion buttons so I can test it on a seperate page
Mar 19 '08 #5
webandwe
142 New Member
the problem is.

I have to post the yes or no to th nex page and also insert it into the form action.

And this is a bit tircky.
Mar 19 '08 #6
webandwe
142 New Member
Or you can use JavaScript to change action attribute without reloading page.

Hi,

I don't know javascripting. Do you have an example for me?
Mar 19 '08 #7
arggg
91 New Member
Try
Expand|Select|Wrap|Line Numbers
  1. <form id=".." action="" method="post"><input name="radio" type="radio" value="yes.php" /><input name="radio" type="radio" value="no.php" /><label><input type="submit" name="Submit" value="Submit" /></form>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if ((isset($_POST['radio']) && isset($_POST['Submit']))
  3. {
  4.     include($_POST['radio']);
  5. }
  6. else
  7. {
  8.     //include the form here
  9. }
  10.  
  11. ?>
  12.  
Mar 19 '08 #8
arggg
91 New Member
you can try this for javascript

Expand|Select|Wrap|Line Numbers
  1. <form name="RadioForm" action="#"method="post"><input name="radio" type="radio" value="yes.php" onClick="javascript:actionCheck('yes.php');" /><input name="radio"type="radio" value="no.php" onClick="javascript:actionCheck('no.php');" /><label><inputtype="submit" name="Submit" value="Submit"></form>
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function actionCheck($action)
  3. {
  4.     document.RadioForm.action = $action;
  5. }
  6. </script>
  7.  
I have not tested this so i am unsure if it works.
Mar 19 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2109
by: php newbie | last post by:
Hello, I am learning php. I have created a simple Web page with a form. After receing the POST request, I do some error checking. In case of errors, I would like to re-post the page, but with...
27
3039
by: Ron Adam | last post by:
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a...
1
4157
by: Andrés Giraldo | last post by:
Hi! I'm trying to pass trough all the objects of a form but I have some text inputs in a DIV and I have many DIVs like this on my form. I'm doing something like: for (i = 0; i <...
40
2987
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
12
3201
by: junky_fellow | last post by:
Which is better using a switch statement or the if-then equivalent of switch ?
1
1108
by: reidarT | last post by:
In vb.net 2005 I try to close a form if it is opened with if isloaded("formname") then formname.close() but it doesn't work
1
2620
by: ConfusedMay | last post by:
Hi, I'm working on a database that has a form which hold all of our products testing. each product can hold more than 1 complete test (complete test here means that product has to have before and...
5
6499
by: wassimdaccache | last post by:
Hello everybody I'm using access 2003 Sometimes I use to open more than form in my project what I need is to check another form if still opened For example I have : form name X,Y,Z
2
1476
by: nixan | last post by:
Hai all im new to this forum and begin to learn php. Here is a problem which may be very simple to you but it is problem to me. how can choose SELECT tag from a form if there are multiple SELECT...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.