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 to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation how to check check with respect to database values

    I written following program.but this program is not giving proper output
    if $homepage=1 then it check checkbox1
    <html>

    <?php
    $homepage=1;
    switch($homepage)
    {
    case 1:{echo "<script>document.getElementById('homepage1').checked;</script>";
    break;}
    case 2: {echo "<script>document.getElementById('homepage1').checked;</script>";
    break;}
    default:{}
    ?>
    <body>
    <form>
    <input type="checkbox" id="homepage1" value="1"/>
    <input type="checkbox" id="homepage2" value="2"/>
    </form>
    </body>
    </html>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    I think you need something like below.
    PHP Code:
    <input type="checkbox" id="homepage1" value="1" <?php echo ($homepage==1?'checked="checked"':'' ); ?>/>
    <input type="checkbox" id="homepage2" value="2" <?php echo ($homepage==2?'checked="checked"':'' ); ?>/>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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