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
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts

    if checkbox checked....

    Hi. I'm making a website that includes a form, and I kind of hit a bump with the php.
    Code:
    PHP:
    {for($i=0; $i<22; $i++)
        {if($_POST["Navs".$i]=='ON')
         {$message.=$i.", ";}}
    
    HTML:
    <tr><td width="425"><input type="checkbox" id="Navs0" onClick="Cont_pag5_3()"><img name="But_nav" src="buttons/a_la_carte_p1.jpg" onMouseOver="Nav_but(0, 0)" onMouseOut="Nav_but(1, 0)" onMouseDown="Nav_but(2, 0)" onMouseUp="Nav_but(0, 0)"></td>
    <td width="425"><input type="checkbox" id="Navs1" onClick="Cont_pag5_3()"><img name="But_nav" src="buttons/artemis_p1.jpg" onMouseOver="Nav_but(0, 1)" onMouseOut="Nav_but(1, 1)" onMouseDown="Nav_but(2, 1)" onMouseUp="Nav_but(0, 1)"></td></tr>
    <tr><td width="425"><input type="checkbox" id="Navs2" onClick="Cont_pag5_3()"><img name="But_nav" src="buttons/aura_p1.jpg" onMouseOver="Nav_but(0, 2)" onMouseOut="Nav_but(1, 2)" onMouseDown="Nav_but(2, 2)" onMouseUp="Nav_but(0, 2)"></td>
    <td width="425"><input type="checkbox" id="Navs3" onClick="Cont_pag5_3()"><img name="But_nav" src="buttons/avail_p1.jpg" onMouseOver="Nav_but(0, 3)" onMouseOut="Nav_but(1, 3)" onMouseDown="Nav_but(2, 3)" onMouseUp="Nav_but(0, 3)"></td></tr>
    ETC to Navs21
    The problem is that the php doesn't "see" if the checkboxes ar checked or not, so that part of $message remains empty...What am I doing wrong? Thank you in advance. Bye.

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    not really sure what you're trying to do but if you want the form to remember if the checkbox has been checked or not, do this

    PHP Code:
    <input name="chk" type="checkbox" value="" <?php if(isset($_POST['chk'])) { echo 'checked="true"'; } ?> />


  •  

    Posting Permissions

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