473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Form in 2 steps - Preserving button radio

Hello. Yes, already ask but no answers for this little problem.
I've got a form and 3 steps or page for the same form. If we come back
to the first page, the states of button radio are lost.

First page (form1.php)
<?
$gender=$_POST['gender'];
if(isset($_POST['gender'])){
$statusm="";
$statusf="";
if($_POST['gender']=="M"){$statusm="checked"}
else{$statusf="checked"}
?>

<Form... action="form2.php">
....
<input name="gender" type="radio" id="male" value="M"<?php echo
$statusm
?>M
<input name="gender" type="radio" id="female" value="F"<?php echo
$statusf ?>>F
....
</Form>

Second page (form2.php)
<?
$Gender=$_POST['gender'];
?>

<Form... action="form1.php">
....
<input name="gender" type="hidden" id="gender" value="<? echo $gender ?
>" />
....
</Form>

But it doesn't work!!!

A solution could be with "session_start()" and $_cookie but I don't
know how to do it!

If anybody could write me all I need on the two pages with a little
exemple?? (The same problem come with the checkox or choise with
dynamic menu!) Thanks, pascal

Feb 22 '07 #1
6 1799
elia schreef:
Hello. Yes, already ask but no answers for this little problem.
I've got a form and 3 steps or page for the same form. If we come back
to the first page, the states of button radio are lost.
A solution could be with "session_start()" and $_cookie but I don't
know how to do it!

One way to do it.

foreach ($_POST as $key=>$val)
{
echo '<input type = "hidden" name="'.htmlentities($key).'"
value="'.htmlentities($val).'" />';
}

--
Arjen
http://www.hondenpage.com - Mijn site over honden
Feb 22 '07 #2
Thanks but it's doesn't work for button radio... pascal

Feb 22 '07 #3
On 22 Feb, 07:45, "elia" <jos...@pcl.chwrote:
Hello. Yes, already ask but no answers for this little problem.
I've got a form and 3 steps or page for the same form. If we come back
to the first page, the states of button radio are lost.

First page (form1.php)
<?
$gender=$_POST['gender'];
if(isset($_POST['gender'])){
$statusm="";
$statusf="";
if($_POST['gender']=="M"){$statusm="checked"}
else{$statusf="checked"}
?>

<Form... action="form2.php">
...
<input name="gender" type="radio" id="male" value="M"<?php echo
$statusm
?>M
<input name="gender" type="radio" id="female" value="F"<?php echo
$statusf ?>>F
...
</Form>

Second page (form2.php)
<?
$Gender=$_POST['gender'];
?>

<Form... action="form1.php">
...
<input name="gender" type="hidden" id="gender" value="<? echo $gender ?>" />

...
</Form>

But it doesn't work!!!

A solution could be with "session_start()" and $_cookie but I don't
know how to do it!

If anybody could write me all I need on the two pages with a little
exemple?? (The same problem come with the checkox or choise with
dynamic menu!) Thanks, pascal
When re-writing the button code on form1 include CHECKED on the one
that should be selected

Feb 22 '07 #4
elia schreef:
Thanks but it's doesn't work for button radio... pascal
offcourse it does.
on page 1
echo '<input type = "radio name="gender" value="female" />';
echo '<input type = "radio name="gender" value="male" />';

on page 2
foreach ($_POST as $key=>$val)
{
echo '<input type = "hidden" name="'.htmlentities($key).'"
value="'.htmlentities($val).'" />';
}
on page 3
// do this any way u like. This will give an error in safe mode.
$checked[$_POST['gender']]='checked="checked"';
echo '<input type = "radio" name="gender" value="female"
'.$checked['female'].'/>';
echo '<input type = "radio" name="gender" value="male"
'.$checked['male'].'/>';
echo 'Your gender is'.$_POST['gender'];

if it doen't work post the output of var_dump($_POST); did you set your
form right ?

--
Arjen
http://www.hondenpage.com - Mijn site over honden
Feb 22 '07 #5
elia wrote:
Hello. Yes, already ask but no answers for this little problem.
I've got a form and 3 steps or page for the same form. If we come back
to the first page, the states of button radio are lost.

First page (form1.php)
<?
$gender=$_POST['gender'];
if(isset($_POST['gender'])){
$statusm="";
$statusf="";
if($_POST['gender']=="M"){$statusm="checked"}
else{$statusf="checked"}
?>

<Form... action="form2.php">
...
<input name="gender" type="radio" id="male" value="M"<?php echo
$statusm
?>M
<input name="gender" type="radio" id="female" value="F"<?php echo
$statusf ?>>F
...
</Form>

Second page (form2.php)
<?
$Gender=$_POST['gender'];
?>

<Form... action="form1.php">
...
<input name="gender" type="hidden" id="gender" value="<? echo $gender ?
>" />
...
</Form>

But it doesn't work!!!

A solution could be with "session_start()" and $_cookie but I don't
know how to do it!

If anybody could write me all I need on the two pages with a little
exemple?? (The same problem come with the checkox or choise with
dynamic menu!) Thanks, pascal
Look at your source code. I think you'll find this comes out to

<input name="gender" type="radio" id="male" value="M"CHECKEDM

Note the lack of a space between "M" and CHECKED.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Feb 22 '07 #6
Extra!! All is ok, I had the same problem for the selected menu but is
ok now with the same code, thanks a lot for all!! Pascal

Feb 23 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: A.Kelly | last post by:
Two problems that I'm having (due to being a n00bie) are: The form I'm using is the basic form with a username, email address etc.. the two that I'm most concerned about are the Gender, and...
1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
5
by: Fran Jakers | last post by:
Hello all, I'm new to all this and I could really use some help. I've searched the web but cannot find an answer. I have an HTML form with 3 radio buttons and a search field that calls a...
1
by: mirandacascade | last post by:
1) Module1 has the following delcaration: Public g_frmZZZ as Form Public g_txtForm2 as Variant 2) app has two forms: form1 and form2 3) a command button on form1 opens form2; it also has...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.