dsjq6977 2013-04-05 12:12
浏览 35
已采纳

Javascript函数不会在php页面中执行[关闭]

I have simple html page which contains a javascript function which adds rows, but when i embed into my php page it does not execute. It is the onclick function which does not work. The other button works fine. i'm at a loss to why. I'm fairly new to programming.

        $content .="
    <html>
<head>
<title>Add Items To Repair</title>
<script language='javascript'>
row_no=0;
function addRow(tbl,row){
row_no++;
if (row_no<=20){
if (row_no>=10){
var textbox  = row_no+'.)<input type='text' size = '2'  maxlength= '2' name= quantity[]>';}
if (row_no<10){
var textbox  = row_no+'.  )<input type='text' size = '2'  maxlength= '2' name= quantity[]>';}
var textbox2 = '<input type='text' size = '100' maxlength= '100' name= desc[]>';
var textbox3 = '<input type='text' size = '20' maxlength= '20' name= productno[]>';
var textbox4 = '<input type='text' size = '20' maxlength= '20' name= issue[]>';
var tbl = document.getElementById(tbl);
var rowIndex = document.getElementById(row).value;
var newRow = tbl.insertRow(row_no);
var newCell = newRow.insertCell(0);
newCell.innerHTML = textbox;
var newCell = newRow.insertCell(1);
newCell.innerHTML = textbox2;
var newCell = newRow.insertCell(2);
newCell.innerHTML = textbox3;
var newCell = newRow.insertCell(3);
newCell.innerHTML = textbox4;

}
if (row_no>12){
alert ('Too Many Items. Limit of 12.'); 
}
}


</script>

</head>


<body>
<form name='invoice' method='post' action='insert.php'>

<input type='submit' value='Create Repair Ticket'>
<input type='button' name='Button' value='Add Items to Repair Ticket' onClick='addRow('table1','row1')'>
<table width='1000' border='0' cellspacing='0' cellpadding='2' id='table1'>
<th><center>QTY</th>
<th>Item Description</th>
<th>ProductNumber</th>
<th>Issue</th>
</center>
<tr id='row1'>
</tr>
</table>

 <table align='center' width='80%'> 
        <tr> 
            <td align='right'><input type='submit' name='checkin' value='Submit'></td><td><input type='reset' name='reset' value='Reset'></td> 
        </tr> 
    </table> 
</form>
</body>
</html>
"; 
  • 写回答

2条回答 默认 最新

  • drlh197610 2013-04-05 12:16
    关注

    replace with :

    <input type='button' name='Button' value='Add Items to Repair Ticket' onClick='addRow(\'table1\',\'row1\')'>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试