vendredi 4 novembre 2016

Can't see input radio checked, but it is in code

i'm stuck in a weird problem with a page

<table class='table'>
<?      
    print_r($selected_working_time);
    // it print a previous selection of working time. for example: 
    // Array ( [0] => 5 [1] => 6 [2] => 4 [3] => 7 [4] => 9 [5] => 8 )

    $query="SELECT Working_time_code, Working_time_description
                    FROM Working_time
                    ORDER BY Working_time_description";
    // a table with a working_time code and his description. for example:
    // 1 - Part-time; 2 - Full-time, ..., 9 - 10:00 - 16:00

    if($stmt = $connection->prepare($query)) {

        $stmt->execute();
        while($all_working_time = $stmt->fetch(PDO::FETCH_ASSOC)) {

            $desc = trim($all_working_time['Working_time_description']);
            $code = $all_working_time['Working_time_code'];

            echo"<tr><td>$desc</td>";

            if(in_array($code, $selected_working_time)) { // if code is in my selection, YES checkbox is checked, else NO checkbox is checked.

                echo "<td><label class='radio-inline'><input type='radio' name='$codice' value='Y' checked />YES</label>
                            <label class='radio-inline'><input type='radio' name='$codice' value='N' />NO</label></td>";
            }
            else {
                echo "<td><label class='radio-inline'><input type='radio' name='$codice' value='Y' />YES</label>
                          <label class='radio-inline'><input type='radio' name='$codice' value='N' checked />NO</label></td>";
            }

            echo"</tr>";
        }
    }
?>
</table>

This code works fine, because when i show source code of my generated page i see correctly checked checkbox, but no one of them is really checked.

Where is the problem? It's like a visualization problem, it isn't working with firefox and chrome.

Thank you.




Aucun commentaire:

Enregistrer un commentaire