Preserving form information

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • A.Kelly

    Preserving form information

    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
  • OSIRIS

    #2
    Re: Preserving form information

    A.Kelly wrote:
    [color=blue]
    > 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[/color]
    Hi,

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

    Bye

    Comment

    • Geoff Berrow

      #3
      Re: Preserving form information

      I noticed that Message-ID:
      <79609ed4.03112 22051.7b9d4f41@ posting.google. com> from A.Kelly contained
      the following:
      [color=blue]
      >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?[/color]

      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/

      Comment

      Working...