s i can’t use css to make my auto numbering for my tables with css using TCPDF.I’m trying to use Javascipt to make this work. I read the documentation [this] and this this(Example 053 : javascript functions · TCPDF) on how to add javascript into my tcpdf. But i do not know why it does not work and it shows the error of Parse error: syntax error, unexpected 'var' (T_VAR) in C:\filepath\XAMPP\htdocs\filepath\customerinvoice.php on line 211
Can i know how can i define my ‘var’ in tcpdf? Or is not possible to add javascript in TCPDF? Please help me with this issue. Any help will be apprecialted. Thanks in advance
These are my codes
$htmlcontent .='
<table cellpadding="7" style="max-height: 1000px;">
<tr class="receiptcontent">
<td style="font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
</td>
<td width= "30%" colspan="3" style="font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
'.$irow['product_name'].'
</td>
<td style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
'.$irow['product_code'].'
</td>
<td width= "15%" style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
'.$irow['quantity'].' '.$irow['quantity_unit'].'
</td>
<td width= "15%" style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
RM '.$irow['original_price'].'
</td>
<td width= "20%" style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
RM '.$irow['price'].'
</td>
</tr>
</table>
';
}
This is the javascript i added in to implement auto numbering for my tables
$js =
var table = document.getElementsByTagName('table')[0],
rows = table.getElementsByTagName('tr'),
text = 'textContent' in document ? 'textContent' : 'innerText';
for (var i = 0, len = rows.length; i < len; i++) {
rows[i].children[0][text] = i + ': ' + rows[i].children[0][text];
};
// Add Javascript code
$pdf->IncludeJS($js);
$pdf->writeHTML($htmlcontent);
ob_end_clean();
$pdf->Output('customerinvoice.pdf', 'I');