我在一個PHP項目的工作,禁用和啓用onclick事件不工作的多行
好,我需要幫助像我有10條記錄的數據更新到數據庫中看到如下─診斷
現在喜歡你看到No_Info選項,說:No_Data和Available。
所以,當用戶點擊ID爲1的No_data時,它會禁用附加到相應ID的字段。 和相同的可用作品。
但它只是所有工作的ID:1,不爲別的,排它的工作.....
編輯:這裏更新的代碼。
>>>> <?php
//connect to the database server
$objConnect = mysql_connect("localhost","root","") or die(mysql_error());
//select the database
$objDB = mysql_select_db("main_project");
//select which data you want to get.
$sql = "SELECT * FROM website_maindb";
$objQuery = mysql_query($sql);
// $Ct = mysql_query('select * from company_type');
/* $objResult = mysql_fetch_array($objQuery); // Not to use when using loop to call full database */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ss</title>
<script>
function disable()
{
document.getElementById("noi1").disabled=true;
document.getElementById("noi2").disabled=true;
document.getElementById("noi3").disabled=true;
document.getElementById("noi4").disabled=true;
document.getElementById("noi5").disabled=true;
document.getElementById("noi6").disabled=true;
}
function enable()
{
document.getElementById("noi1").disabled=false;
document.getElementById("noi2").disabled=false;
document.getElementById("noi3").disabled=false;
document.getElementById("noi4").disabled=false;
document.getElementById("noi5").disabled=false;
document.getElementById("noi6").disabled=false;
}
</script>
</head>
<body>
<form id="form" action="insert.php" method="post">
<table width="700" border="1">
<tr>
<th></th>
<th width="20"> <div align="center">ID </div></th>
<th width="98"> <div align="center">website </div></th>
<th width="98"> <div align="center">category </div></th>
<th width="98"> <div align="center">email </div></th>
<th width="98"> <div align="center">contact form </div></th>
<th width="98"> <div align="center">Primary No. </div></th>
<th width="98"> <div align="center">Secondary No. </div></th>
<th width="98"> <div align="center">fax </div></th>
<th width="98"> <div align="center">Company type </div></th>
<th width="98"> <div align="center">No_Info </div></th>
<th width="98"> <div align="center">time </div></th>
</th>
</tr>
<?php
$options = '';
$Ctype=mysql_query("select distinct typec from company_type");
while($row = mysql_fetch_array($Ctype)) {
$options .="<option>" . $row['typec'] . "</option>";
}
?>
<?php
$i = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
?>
<tr>
<td><input type="hidden" name="WID" value="<?=$objResult["WID"];?>"></td>
<td><label><input type="text" name="ID" value="<?=$objResult["WID"];?>" disabled></label></td>
<td><input type="text" name="website" value="<?=$objResult["website"];?>"></td>
<td><input type="text" name="cat" size="10"></td>
<td><input type="text" id="noi1" name="email" size="10"></td>
<td><input type="text" id="noi2" name="cform" size="10"></td>
<td><input type="text" id="noi3" name="contactp" size="10"></td>
<td><input type="text" id="noi4" name="contacts" size="10"></td>
<td><input type="text" id="noi5" name="fax" size="10"></td>
<td><select id="Ctype" name="Ctype"> <?=" $options "?> </select></td>
<td><button type="button" onclick="disable()" size="20">No_Data</button> </br>
<button type="button" onclick="enable()" size="20">Available</button>
</td>
<td><input type="text" id="noi6" name="time" size="10"></td>
</tr>
<?php
}
?>
<button type="submit" id="send">Submit</button>
</form>
</table>
</body>
</html>
誰能幫助解決它..
您可能想要在問題中添加代碼,因爲要在pastebin中查看您需要一個帳戶,並且我懷疑是否每個人都有一個pastebin帳戶。 – Daanvn 2013-04-10 07:11:51
這是一個私人粘貼。 – 2013-04-10 07:11:51
1.您通常會在此粘貼相關代碼,因爲pastebin coudl會在某天終止,如果存在,您將無法重新讀取此問題。 2.你的pastebin是私人的! – ITroubs 2013-04-10 07:12:05