mardi 5 janvier 2016

how to enable checkboxes using radio button

I'm working on a school project and i'm trying to enable some checkboxes when a radio button is clicked..I've already searched old questions but nothing helped me so much....so I have this code in a php file

 echo "<table>
            <tr>
                <th>Όνομα</th>
                <th>Επίθετο</th> ";
                for($count = 1; $count <= 13; $count++)
                {   
                    echo"<form action = '../professorPanel/submitAttendance.php' name='radioo' method = 'post'>
                            <th><input type='radio' name='radio' value='".$count." onchange='setFries()' id='radioCh".$count."'><b>".$count."o</b></th>";   
                }           
    echo    "</tr>";
        while($students_i = mysql_fetch_array($students))
        {
            $id=$students_i["studentID"];
            $class=$students_i["studentclassID"];

            echo"
                <tr>
                    <td>".$students_i["firstName"]."</td>
                    <td>".$students_i["lastName"]."</td>";
                    for ($count = 1; $count <= 13; $count++) 
                    {
                       echo"<td> 
                            <input type = 'checkbox' disabled name = 'attendance[]' value = '$id' id='check".$count."'/>
                                <input type = 'hidden' name = 'class' value = '".$class."' />   
                                </td>";
                    } 
        }           

            echo"   
            <input type = 'submit' name = 'submit' value = 'Υποβολή' /><br>
                            </form>

Once a radio button is selected from any td i want the checkboxes to be enabled..So i found from an old question this js code but its not really works for me :/ Any help?What am i doing wrong?

                        <script type='text/javascript'>
                        function setFries()
                        {
                            var el = document.getElementById('radioCh1');
                            if(el.checked)
                                document.getElementById('check1').disabled = false;
                            else
                                document.getElementById('check1').disabled = true;    
                        }  
                    </script>";`




Aucun commentaire:

Enregistrer un commentaire