Results 1 to 3 of 3

Thread: Check checkbox after event

  1. #1
    Registered
    Join Date
    Apr 2013
    Location
    Zambia
    Posts
    2
    Rep Power
    0

    Exclamation Check checkbox after event

    PHP Code:
    <?php
     $con
    =mysqli_connect("localhost","root","","User_db");
     
    // Check connection
     
    if (mysqli_connect_errno())
       {
       echo 
    "Failed to connect to MySQL: " mysqli_connect_error();
       }

     
    $result mysqli_query($con,"SELECT * FROM Assessments");

     echo 
    "<table class='sortable' border='0' cellpadding='40'
    cellspacing='0'>
    <thead>
     <tr>
     <th>Title</th>
     <th>Lecturer</th>
     <th>Start</th>
     <th>Due</th>
     <th>Completed</th>
     </tr>
     </thead>"
    ;

     while(
    $row mysqli_fetch_array($result))
       {
       echo 
    "<tr>";
       echo 
    "<td>" $row['Title'] . "</td>";
       echo 
    "<td>" $row['Lecturer'] . "</td>";
       echo 
    "<td>" $row['Start'] . "</td>";
       echo 
    "<td id='Due'>" $row['Due'] . "</td>";
       echo 
    "<td>" ."<input type='checkbox' id='mycheckbox' name='Completed' value='Completed' />";
       echo 
    "</tr>";
       }
     echo 
    "</table>";

     
    mysqli_close($con);
     
    ?>
    Hello guys I was wondering if using javascript, the checkbox would get check when the date on $row['Due'] is reached for exams 14/04/2013 is the date. The checkbox should automatically get the date and check the checkbox permanently.

  2. #2
    target='_blank' snowmaker's Avatar
    Join Date
    Nov 2002
    Location
    West Virginia
    Posts
    3,458
    Rep Power
    22
    This can be done with PHP, JS isn't needed. I'm sorry that I don't have the time or inkling to spew some example code at you, but the logic path I'm thinking of is to compare the $row['Due'] variable with a defined date, and whether or not they're equal, echo the corresponding line of HTML. ie: if the if is true, echo the the input tag line with the 'selected' parameter in it..

    Hope this helps..

    edit: oh yeah, whether you're a customer or not (and I doubt you are), Welcome to the Powweb Forums!
    Last edited by snowmaker; 4-13-13 at 02:35 PM. Reason: welcome!
    -bruce /* somdcomputerguy */
    'If you change the way you look at things, the things you look at change.'

  3. #3
    Registered
    Join Date
    Apr 2013
    Location
    Zambia
    Posts
    2
    Rep Power
    0

    Smile

    Quote Originally Posted by snowmaker View Post
    This can be done with PHP, JS isn't needed. I'm sorry that I don't have the time or inkling to spew some example code at you, but the logic path I'm thinking of is to compare the $row['Due'] variable with a defined date, and whether or not they're equal, echo the corresponding line of HTML. ie: if the if is true, echo the the input tag line with the 'selected' parameter in it..

    Hope this helps..

    edit: oh yeah, whether you're a customer or not (and I doubt you are), Welcome to the Powweb Forums!
    Thanks. Ya I get what you're trying to. And thanx for the welcome . I got the same logic too but I didn't know any sort of code to implement it.

Posting Permissions

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