I have iterated a table based on my query result... I have a column lastDate
it contains a date value like 01/24/2010
... Now i have to check the date value with the current date if currentdate
is less than or equal to lastDate
i have to enable the checkbox else disable it..... Any suggestion how it can be done in php...
Here is my code
<? if(isset($comment))
{ echo '<tr><td class=table_label colspan=5>'.$comment.'</td></tr>'; } ?>
<?php foreach($getassignmentdata as $row) { ?>
<td align="center" class="table_label" id="txtsubdat">
<?
开发者_JAVA技巧 $dd=$row['dDate'];
if($dd=='')
{
}
else
{
$str = $dd;
$dd = strtotime ( $str );
echo date ( 'm/d/Y' , $dd );
} ?>
</td>
<td align="center">
<input type="checkbox" name="group" id="group"
value="<?=$row['dAssignment_id']?>" onclick="checkdisplay(this);">
</td>
<? } ?>
i tried this and it worked..
<input type="checkbox" name="group" id="group" value="<?=$row['dAssignment_id']?>"
<?php
$dd=$row['dDate'];
if($dd=='')
{
}
else
{
$str = $dd;
$dd = strtotime ( $str );
if((date('m/d/Y')) <= (date('m/d/Y',$dd)))
{
echo 'enabled';
}
else
{
echo 'disabled';
}
}
?> onclick="checkdisplay(this);">
In HTML, you can disable a checkbox using the disabled
attribute.
<input type="checkbox" disabled>
In PHP, you can control HTML output dynamically using embedded scripts.
<input type="checkbox" <?php if (somecondition) echo 'disabled'; ?>>
This will print the disabled
attribute whenever somecondition
evaluates true
.
精彩评论