日期:2014-05-17  浏览次数:20419 次

为啥所有按钮只控制同一行数据???
为啥所有按钮只控制同一行数据?应该怎么解决啊。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="javascript" type="text/javascript">
         function showtd(num) {            
             document.getElementById("bg"+num).style.display = "none";
             document.getElementById("show"+num).style.display = "block";
             document.getElementById("ba"+num);
             document.getElementById("gn"+num);
         }
         function hidetd(num) {
             document.getElementById("bg"+num).style.display = 'block';
             document.getElementById("show"+num).style.display = 'none';
         }
function showtext(){
document.getElementById("a").removeAttribute("readOnly");
document.getElementById("b").removeAttribute("readOnly");
document.getElementById("c").removeAttribute("readOnly");
document.getElementById("d").removeAttribute("readOnly");
document.getElementById("e").removeAttribute("readOnly");
document.getElementById("f").removeAttribute("readOnly");
}
function hidetext(){
document.getElementById("a").readOnly="true";
document.getElementById("b").readOnly="true";
document.getElementById("c").readOnly="true";
document.getElementById("d").readOnly="true";
document.getElementById("e").readOnly="true";
document.getElementById("f").readOnly="true";
}

     </script>
</head>
<body>
<form>
<table border="1">
<?php
$db = mysql_connect('localhost','root','root');
mysql_select_db('ec',$db);
if (!$db)
  {
  die('Could not connect: ' . mysql_error());
  }
$result = mysql_query("select * from goods");
echo "<tr>
<th>GoodsID</th>
<th>BarCode</th>
<th>GoodsName</th>
<th>Category</th>
<th>Specifications</th>
<th>Manufacturers</th>
<th>Numbers</th>
<th>Instructions</th>
<th>Pictures</th>
<th>Update</th>
<th>Delete</th>
</tr>";
$n = 0;
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . "<input type='text' id='a' value='$row[barcode]' style='width:60px;border:0px' readOnly>" . "</td>";
  echo