By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Preserving form information

P: n/a
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 State
form entries.

Gender is of course two radio buttons.

<input name="gender" type="radio" id="male" value="M"> M
<input name="gender" type="radio" id="female" value="F">F

None of the two are checked by default, but what I'd like to do is
this.. if the user doesn't enter a required information field, keep
the information that he has listed thus far. So if they entered M or
F, but didn't enter a required field and the form reloads I want their
chioce to still be 'checked'.

With the other forms this works fine, for example, with $first_name =
$_post['first_name'] and the forms value of <? echo $first_name ?>
But, boiling it all down to my main question - How do I keep the radio
button information for the reloaded form?
Thanks in advance for any information,
A.Kelly
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
A.Kelly wrote:
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 State
form entries.

Gender is of course two radio buttons.

<input name="gender" type="radio" id="male" value="M"> M
<input name="gender" type="radio" id="female" value="F">F

None of the two are checked by default, but what I'd like to do is
this.. if the user doesn't enter a required information field, keep
the information that he has listed thus far. So if they entered M or
F, but didn't enter a required field and the form reloads I want their
chioce to still be 'checked'.

With the other forms this works fine, for example, with $first_name =
$_post['first_name'] and the forms value of <? echo $first_name ?>
But, boiling it all down to my main question - How do I keep the radio
button information for the reloaded form?
Thanks in advance for any information,
A.Kelly

Hi,

I think you can reloaded the formwith a php script: with an argument in
the url: form.php?gender=M or F.

Bye

Jul 17 '05 #2

P: n/a
I noticed that Message-ID:
<79**************************@posting.google.com > from A.Kelly contained
the following:
With the other forms this works fine, for example, with $first_name =
$_post['first_name'] and the forms value of <? echo $first_name ?>
But, boiling it all down to my main question - How do I keep the radio
button information for the reloaded form?


add variables to the buttons

Then it's just an if statement

if(isset($_POST['gender'])){
$statusm="";
$statusf="";
if($_POST['gender']=="M"){$statusm="checked"}
else{$statusf="checked"}
}
<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

Untested.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.