//我的問題是當我的checkit()函數被調用時,它只在數組中的第一項旁邊顯示check.png圖像。javascript onclick屬性如何用於循環數組的更多輸出?
<?php
require 'connectit.php';
if($result = $db->query("SELECT * FROM people ORDER BY id")) {
if($count = $result->num_rows) {
echo "<h3>He's got $count bills to pay.</h3>";
echo "<p>";
while($row = $result->fetch_object()) {
echo "<div id=\"check\" onClick=\"checkit();\"><img id=\"img\" src=\"\" /></div>";
$id = $row->id;
echo $row->bill_name, ': $', $row->bill_cost,
' ',"<a href=\"delete_id.php?id=" . $id . "\">X</a><br/><br/>";
echo "</p>";
}
}
}
?>
//javascript onclick function
<script type="text/javascript">
function checkit(){
document.getElementById("img").src = "check.png";
//needed to put a line through the text, to mark through it but can't figure that out either. I tried this.
document.getElementById("p").style.texttransform = "underline"; //didn't work for me.
}
</script>
謝謝,是的,他們立即檢查他們是否有辦法讓他們檢查個人?希望我可以用javascript打開和關閉它。 –
@DrewPeer你也可以檢查List Index的id是否等於你想改變的' id'。檢查我的更新。 – alexandreferris
問題是他們都有相同的標識,他們仍然都檢查。我希望我可以向你發送文件。它也是活的。 [email protected]如果你有興趣看看它的樣子。 –