$query = mysqli_query( $connection, "SELECT * FROM student");
while($record = mysqli_fetch_assoc($query)) {
echo "<tr>"."<td>".$record['std_id']."</td>"."<td>".$record['std_name']."</td>"."<td>". $record['age']."</td>"
."<td>".$record['phone']."</td>".
"<td>"."<input type='"."checkbox"."' name = '"."vertical"."' id = '".$record['std_id']."' onclick = '".
"(this.checked)? check(".$record['std_id'].",".$record['std_name'].",".$record['age'].",".$record['phone'].") : uncheck()"."'>"."</tr>";
}
the previous code put my database into a table and there is a check box at the end of each raw. when I check it a function -that I write between <script>
tag and and put it in <head>
tag- is called
<script>
function check($name, $age, $phone)
{
document.getElementById("stdname").value = $name;
document.getElementById("stdage").value = $age;
document.getElementById("stdphone").value = $phone;
}
function uncheck()
{
document.getElementById("stdname").value = "";
document.getElementById("stdage").value = "";
document.getElementById("stdphone").value = "";
}
</script>
the problem is I can't pass the values of $record[]
to the function check()
, but it works just fine if there is no parameters in it.
Any Ideas?
Aucun commentaire:
Enregistrer un commentaire