Help with populating checkboxes...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pepe_lepew1962
Forum Commoner
Posts: 44
Joined: Thu Nov 20, 2008 10:29 am

Help with populating checkboxes...

Post by pepe_lepew1962 »

I am having problems with populating checkboxes. After I call up a record, one of the fields has a bunch of characters that I use to determine which checkboxes to populate on the form. I extract each character via "strpos" to variables. I then have the checkbox form check if the status is "on". That all seems to work fine until I want to change the status of the checkboxes. The change is somehow not being taken over. I know how to update the record of the change, but I have to be able to change the fields/variables first.

Code: Select all

<?php
//
//
$pepe01 = strpos($pepe00, "A");
$pepe02 = strpos($pepe00, "B");
//
//
    if ($pepe01 == "A")
    {
        $pepe11 = "on";
    }
//
//
?>
<html>
<tr>
    <td align="left" width="35"><font color="#00ff00" face="Arial" size="2">&nbsp;</font>
        <input type="checkbox" name="checkbox01" <?php if($pepe11 == "on"){echo "CHECKED";}?>></td>
    <td align="left"><font color="#00FF00" face="Arial" size="2">&nbsp; Alex</font></td>
</tr>
</html>
Last edited by Benjamin on Fri Apr 09, 2010 11:02 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
jthermane24
Forum Newbie
Posts: 16
Joined: Wed Feb 17, 2010 8:15 pm
Location: New Jersey

Re: Help with populating checkboxes...

Post by jthermane24 »

The proper syntax for CHECKED is checked="checked"

Change the echo in your php script in the input
Post Reply