SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast charmaine's Avatar
    Join Date
    Apr 2006
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Loseing Checkbox values on every refresh

    Hi

    I am working on a contact form. My problem is that i lose the values of the checkbox everytime the person fill in the contact form incorrect. The form has been validated so it refresh the page everytime there is an incorrect value.

    Everytime the page refresh the persone needs to fill in the checkboxes again.
    I want to make the form so that if the page is refreshed that the perone dont need to fill in the checkboxes again.

    this is the one of the checkboxes

    <input name="male" type="checkbox" id="male" value="checkbox">

    I will need to do the same for a list menu to

    <select name="title" class="blackmain">
    <option value="mr">Mr</option>
    <option value="miss">Miss</option>
    <option value="dr">Dr</option>
    <option value="prof">Prof</option>
    <option value="rev">Rev</option>
    </select>

    Can anyone help please

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    for your checkboxes:

    PHP Code:
    <input name="male" type="checkbox" id="male" <?php if(isset($_POST['male'])) { echo ' checked'; } ?> />
    For your selects:
    PHP Code:
    <select name="title" class="blackmain">
    <?php if(isset($_POST['title'])) { ?>
    <option selected><?php echo $_POST['title']; ?></option>
    <?php ?>
    <option value="mr">Mr</option>
    <option value="miss">Miss</option>
    <option value="dr">Dr</option>
    <option value="prof">Prof</option>
    <option value="rev">Rev</option>
    </select>
    Should do you
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast charmaine's Avatar
    Join Date
    Apr 2006
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much

    That did the trick

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    pleasure
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •