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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.