Jump to content

how to enable checkbox


phpbigenner

Recommended Posts

i have a problem on how to trap the time to enable the checkbox, can you help? example. the db name is time_schedule then the fields are 'time_start' and 'time_end' then there's a checkbox inside the html. my problem is how to enable the checkbox if the time schedule is not equal to the 'time_start' and 'time_end' value. need help guy's

Link to comment
https://forums.phpfreaks.com/topic/281222-how-to-enable-checkbox/
Share on other sites

You need to supply some sample data or something. What field types are time_start and time_end: time, datetime, timestamp, ??? And, what is the value of the "time schedule"? Does it have a start and end time?

 

But, you probably have two choices:

 

1. Do all the logic in PHP. Select your records from the database and then compare the fields when processing each record to determine if the checkbox should be enabled or not.

 

2. Use the comparison in the query to dynamically return a Boolean value on whether the checkbox should be enabled or not.

 

In either case the final code could likely look something like this:

 

while($row = mysql_fetch_assoc($result))
{
    $disabled = (CONDITION) ? ' disabled="disabled"' : '';
    echo "<input type="checkbox" name=\"{$row['field_name']}\" {$disabled} value=\"{$row['valule']}\" /> {$row['label']}";
}

 

CONDITION will either be the logic that you do in PHP or the dynamic value you calculated in the query

Um, ok, you still haven't provided examples of what the data looks like. How can I provide an example of how you would compare those values when I don't know what format they are in? Also, if you are storing the values in the database as text and not as appropriate field types for a "time" element, then you are doing it wrong.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.