【发布时间】:2015-01-23 20:47:04
【问题描述】:
我的 ASP.NET 页面中有一个文本框。更改文本框内的值时会触发 javascript 函数。
知道为什么会出现此错误吗?
错误:
0x800a138a - JavaScript 运行时错误:预期函数
ASP.NET 代码:
<asp:TextBox ID="entryRates" Width="80" onChange="return showAlert(this);" runat="server" CssClass="TextBox" />
JS代码:
<script type ="text/javascript" >
function showAlert(obj)
{
if (document.getElementById("rType").value!="HLDR")
{
iput = obj;
//numberic value (positive or negative)
if (isNaN(iput.value))
{
alert("The entered rate is not a number");
return false;
}
//today's rate
tdrate=iput.value
//yesterday rate
if (document.all.item("rType").value!="OTHR")
{
ydrate = iput.parentElement.parentElement.childNodes(2).firstChild.innerText;
}
else
{
ydrate = iput.parentElement.parentElement.childNodes(4).firstChild.innerText;
}
//alert ("yesterdaycode = "+ydrate);
trptg = 1.25 //thresholdPercent
//alert("thresholdPercent = "+trptg);
if (tdrate.length == 0)
{
tdrate=0
}
if (ydrate.length == 0)
{
ydrate=0
}
totchg = (((tdrate / ydrate) - 1) * 100)
if (totchg < 0)
{
totchg = (totchg * -1)
signchg=1
}
else
{
totchg = totchg
signchg=0
}
if (totchg != 100 & totchg > trptg)
{
if (signchg==0)
{var s = "" + Math.round(totchg * 100) / 100}
else
{var s = "-" + Math.round(totchg * 100) / 100}
alert("% Change = "+s)
}
}
}
</script>
【问题讨论】:
-
childNodes是只读属性,不是函数,也不接受参数?
标签: javascript asp.net textbox onchange