Hi I am getting an error that a particular method btnClick is not defined, Where i Have defined it.
Code:
<html>
<head>
<script type="text/javascript">
var c1 = new Calculator("tab1");
//alert(c1);
var c2 = new Calculator("tab2");
function Calculator(id)
{
var elm = document.getElementById(id);
if (elm.attachEvent)
{
elm.attachEvent('onclick', btnClick);
}
else
elm.addEventListener("click", btnClick, false);
}
Calculator.prototype.btnClick = function() {
var button = e.target||e.srcElement;
var buttonValue = button.value;
if(buttonValue != "=")
{
if (buttonValue == "CE")
{
document.getElementById('disply').value = '';
}
else
{
document.getElementById('disply').value += buttonValue;
}
}
focus();
}
function focus() {
document.getElementById("disply").focus();
}
</head>
<body>
<table id="tab1" border="4" align="center" bordercolor="grey" bgcolor="#E8E8E8" cellpadding="4">
<tr> <td colspan="4"><input id="disply1" type="text" size="27" onkeypress="return onlyNumbers(event);" /></td> </tr>
<tr>
<td><input class="btnStyle" type="button" Value="7" /></td>
<td><input class="btnStyle" type="button" Value="8" /></td>
<td><input class="btnStyle" type="button" Value="9" /></td>
<td><input class="btnStyle" type="button" Value="/" /></td>
</tr>
</table>
</body>
</html>
_______________________
pls help..
Why this happens when method is defined.
Is it wrong way to define.