got for this example 8 checkboxes:
<table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"><strong>Technologie</strong></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;">Tec1</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec1]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;">Tec2</td>
<td style="width: 25%; height: 21px;"><input name="Technologie[Tec2]" type="checkbox" value="1" /></td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;">Tec3</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec3]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;"Tec4</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec4]" type="checkbox" value="1" /> </td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;">Tec5</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec5]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;">Tec6</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec6]" type="checkbox" value="1" /> </td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;">Tec7</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec7]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;">Tec8</td>
<td style="width: 25%; height: 21px;"> <input name="Technologie[Tec8]" type="checkbox" value="2" /> </td>
</tr>
</tbody>
</table>
Here is the SQL Table for the poplated Dropdown:
+--------+------+------+------+------+------+------+------+------+------+
| Tec_ID | Tec1 | Tec2 | Tec3 | Tec4 | Tec5 | Tec6 | Tec7 | Tec8 |RanNr |
+--------+------+------+------+------+------+------+------+------+------+
| 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1353 |
| 2 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0000 |
| 3 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1353 |
| 4 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1123 |
| 5 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 2 | 1353 |
| 6 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 2 | 1353 |
| 7 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1993 |
| 8 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1123 |
| 9 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1353 |
| 10 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 1366 |
+--------+------+------+------+------+------+------+------+------+------+
And here the PHP Part how i populate the Dropdown.
<select id="Tec_ID" name="Tec_ID" size="1" >
<option disabled selected value> </option>;
<?php
foreach($connection->query($tec) as $m)
{
if($m['Tec_ID'] == $_GET['Tec_ID']){
$isSelected = 'selected="selected"';
}else{
$isSelected = '';
}
echo "<option value='" . $m['Tec_ID'] . "'".$isSelected." >" .$m['RanNr'] ."</option>";
}
?>
Notice the last Tec8 can be value 1 or 2.
for ex. You see already if I select Tec_ID 1. Tec1 and Tec5 Checkbox should be checked.
But atm I have no idea, how I can handle this in with Javascript/PHP/MSQLCode? Can someone help?
Aucun commentaire:
Enregistrer un commentaire