请查看此代码。我该如何实施?
最近我是这样做的 -
<script type="text/javascript">
function CheckPowerAll() {
if (document.getElementById("PO_ALL").checked == true) {
document.getElementById("PO_PowerSteering").checked = true;
document.getElementById("PO_PowerMirrors").checked = true;
} else {
document.getElementById("PO_PowerSteering").checked = false;
document.getElementById("PO_PowerMirrors").checked = false;
}
}
</script>
<tr>
<td><input name="PO_ALL" type="checkbox" id="PO_ALL" value="checkbox" onclick="CheckPowerAll()" />
Select all <span class="bold">Power Options</span> </td>
</tr>
<tr>
<td><table width="85%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="box2">
<input name="PO_PowerSteering" type="checkbox" id="PO_PowerSteering" value="Power Steering" />
Power Steering<br />
<input name="PO_PowerMirrors" type="checkbox" id="PO_PowerMirrors" value="Power Mirrors" />
Power Mirrors <br /></td>
</tr>
</table></td>
</tr>
<tr>
但现在我需要从 DB 中填充值。
<input name="PO_ALL" type="checkbox" id="PO_ALL" value="checkbox" onclick="CheckPowerAll()" />
Select all <span class="bold">Power Options</span> </td>
</tr>
<tr>
<td><table width="85%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="box2">
<?php
$query = mysql_query("SELECT * FROM vehicle_poweroptions");
while ( $results[] = mysql_fetch_object ($query));
array_pop ( $results );
foreach ( $results as $option ) : ?>
<input name="PO_PowerWindows" type="checkbox" id="PO_PowerWindows" value="<?php echo $option->id; ?>" />
<?php echo $option->type; ?><br />
<?php endforeach; ?>
我该如何实施?