Javascript function will not execute in php page -
i have simple html page contains javascript function adds rows, when embed php page not execute. onclick function not work. other button works fine. i'm @ loss why. i'm new programming.
$content .=" <html> <head> <title>add items 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 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> ";
replace :
<input type='button' name='button' value='add items repair ticket' onclick='addrow(\'table1\',\'row1\')'>
Comments
Post a Comment