我想要一個表格,其中包含數據庫中的單詞及其含義,在另一列中,我希望每行都有複選框,該用戶將檢查它們並顯示他/她知道的單詞。 我在這種情況下有兩個問題: 1-我怎樣才能隱藏在第一個意思,並在點擊後顯示意義可見他們? 2-如何設置複選框? 我有這樣的代碼,到現在爲止,但它不工作 請幫助我,如果你能php中的表格中的複選框
<script type="text/javascript">
function ShowMeanings(){
document.getElementsByClassName('hiding').item(0).style.visiblility = 'visible';
}
</script>
<?php
$con = mysql_connect("localhost", "root", "")
or die(mysql_error());
if (!$con) {
die('Could not connect to MySQL: ' . mysql_error());
}
mysql_select_db("project", $con)
or die(mysql_error());
$result = mysql_query("select * from words");
echo "<table border='1'>
<tr>
<th>word</th>
<th>meaning</th>
<th>check</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['word'] . "</td>";
echo "<td>";
echo "<div";
echo "class='hiding' style='visibility:hidden'>" . $row['meaninig'];
echo "</div>";
echo "</td>";
echo "<td>";
echo "<input";
echo "type= 'checkbox' name = 'checkbox' id = 'checkbox' value = '' />";
echo "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</div>
<button onclick="ShowMeanings()">showmeaning</button>
你通過任何改變知道jquery嗎? – magicianiam
可以顯示任何錯誤或調試代碼。另外$ row ['meaninig']拼寫錯誤...不知道這是否是由設計? :) – devfunkd
我知道這是missplelled,但我沒有改變我的表在數據庫中的列 我hava erro在這裏: document.getElementsByClassName(...)。item(...)是空的document.getElementsByClassName ('hiding')。item(0).style.visiblility ='visible' – fahimeh