Here is a snippet of my HTML:
<tr>
<td class="timeHeader" id="timeInOutString"></td>
<td id="timeControlHours"></td>
<td>:</td>
<td id="timeControlMins"></td>
<td onclick="this.TimeChangeView.AcceptTime()">Accept</td>
</tr>
<tr>
<td></td>
<td onclick="this.TimeChangeView.downHours()">
Javascript:
function TimeChangeView(ac) {
this.downHours = function(){
//get element by Id
var value = parseInt(document.getElementById('timeControlHours').innerHTML);
value = isNaN(value) ? 0 : value;
value--;
//add leading zeroes
value = formatHoursMins(value);
document.getElementById('timeControlHours').innerHTML = value;
}
}
Error:
Uncaught TypeError: Cannot call method 'downHours' of undefined
I have defined it in the script within a method called TimeChangeView, yet it is complaining that I have not defined it, why? Thanks.
downHours. Read the error message carefully. Cannot call method 'downHours' of undefined.TimeChangeViewhas a method calleddownHoursbut undefined doesn't.this.TimeChangeViewreturns undefined becausethisiswindow.