如何在document.getElementById

时间:2016-11-17 02:45:38

标签: javascript php html

AS标题,我想在document.getElementById中创建数组,因为我的id来自重复区域。下面是我的javascript和html。

<script type ="text/javascript">
  $(document).ready(function(){
	  
	  $('table tbody tr').click(function(){
		  
		  var PurchaserID = window.opener.document.getElementById("PurchaserID");
		  var n = 5;
            PurchaserID.value = document.getElementById("test[n]").innerText;
		  alert(PurchaserID.value);
		  
		   window.close();
		
	  });
  });
</script>

  <?php do { ?>
      <tr>
      <td id = "test[<?php echo $row_Purchaser['ID'];?>]"  align="center" ><?php echo $row_Purchaser['ID'];?></td>
      <td align="center"><?php echo $row_Purchaser['Name']; ?></td>
      <td align="center"><?php echo $row_Purchaser['IC']; ?></td>
      <td align="center"><?php echo $row_Purchaser['Handphone']; ?></td>
       </tr>
   <?php } while ($row_Purchaser = mysql_fetch_assoc($Purchaser)); ?>

我的程序有任何问题。为什么我不能得到值test [n]来测试[5],即使我创建var n = 5;我可以知道如何解决它。谢谢,如果你能帮我!!

0 个答案:

没有答案