I am trying to use a function call within a repeat.for
so that I can use variables that come through inside the loop, but it’s not working.
Error:
Uncaught ReferenceError: select_by_age is not defined at HTMLImageElement.onclick
I had been using a click.call
to call the function, but my variables were not defined if I did that, so I changed it to a onclick=
.
Html code:
<table cellpadding="2" cellspacing="4" width="400"
border="0" class="customerinfobg">
<tr repeat.for="aging of aging_table">
<td class="customerinfocellfg" align="right"
valign="center">
${aging.label}
</td>
<td class="customerinfocellfg" align="right"
valign="center">
${aging.dollar_amount}
</td>
<td class="customerinfocellfg" align="center"
valign="center">
${aging.item_count}
</td>
<td bgcolor="#ffffff" valign="center">
<img src="graphs/leftbar.gif" width="4"
height="20"
onclick="select_by_age($aging.from_age, $aging.to_age);">
<img src="./graphs/redbar.gif" width="${aging.redbar}"
height="20"
onclick="select_by_age($aging.from_age , $aging.to_age);">
<img src="graphs/rightbar.gif" width="4" height="20"
onclick="select_by_age($aging.from_age, $aging.to_age);">
</td>
</tr>
</table>
Js code:
select_by_age(min_age, max_age)
{
console.log('min_age', min_age);
console.log('max_age', max_age);
}
I can’t quite figure out what I should be trying to do.