I can’t get this to work. Dropping the JavaScript directly onto the onclick event works fine, but it doesn’t this way.
JavaScript
function checkid(objDivID) {
if(this.id == 'id1') {
alert('ID is Checked')
};
}
HTML
<tr id='id". $row['id'] ."' class='rrtr' onclick=\"checkid(this.id);\">
<td class='name'>". $row['name'] ."</td>
<td class='data'>". $row['TotalResp'] ."</td>
<td class='data'>". $row['StaffCount'] ."</td>
<td class='data'><b>". number_format($row['Perc'],0) ."</b></td>
</tr>
Thanks, H.
You’re passing the function
this.id, but then in the function you try to reference that again. It won’t work. Use the parameter name instead.Also the backslashes quoting the double-quotes in the HTML are probably not really there, right? You’re printing that HTML as a string I presume.