Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Mumbai,India
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Handle check Box

    I am sure this must have been answered but I tried to locate but could not get exact answer

    1. I am reading a database table
    2. Based on its value say $active = "Y"
    3. I want to make the check box checked
    if $acive="Y" then make the check box checked
    else
    keep it unchecked
    4. Also pass(to database) "Y" when the check box is checked and "N" otherwise..


    Please help !!!

    Thanks in advance

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,096
    Thanks
    11
    Thanked 101 Times in 99 Posts
    if checked the variable $_REQUEST['chk']; will have a value on the receiving page , (check for <?if(!empty($_REQUEST['chk'])){/*etc*/}?>

    PHP Code:
    <?
    $CHK 
    = ( $active=='Y' ) ? ' CHECKED' '' ;
    ?>
    <input type="checkbox" name="chk" value="<?=$active;?>"<?=$CHK;?> />
    note that the above HTML is not valid though it will work , I think checked is now an attribute?.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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