Results 1 to 3 of 3

Thread: php syntax to reset a chkbox?

  1. #1
    Join Date
    May 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php syntax to reset a chkbox?

    This php code is in my head section:
    Code:
    if(isset($_POST['Submit'])) {$name=$_POST['name']; $email=$_POST['email']; $comments=$_POST['comments']; $mailing=$_POST['mailing'];
    then some checks to make sure the user entered data in all the fields.

    In the body section, in my form I have this to reload the field after telling the user they didn't fill in completely the form:
    Code:
    <input name="name" type="text" class="text" id="name" value="<?php echo $name; ?>" />
    I also need similar php code for a yes/no checkbox but can't figure it out. It needs to do something like:
    Code:
    <input name="mailing" type="checkbox" id="mailing" value="<?php 'true' or 'false' if ($mailing=='true'; ?>" />
    Can someone suggest the right syntax?

    Thanks,
    Jerol

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <?php echo($mailing === 'true' ? 'false' : 'true'); ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Wow! Thanks, I'll give it a try.

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
  •