value是null还是不是对象,但是它定义了什么? [英] value is null or not an object, but its defined?

查看:105
本文介绍了value是null还是不是对象,但是它定义了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调用这个表单中的函数,并且有值设置

但是每次调用它时都会遇到运行时错误...

document.frmKitAmount.txtTotalKitValue为null或不是对象...

函数是这样的:


函数calc_total()

{

var x,i,base,margin,total,newmargin,newtotal;

base = document.frmKitAmount.txtTotalKitValue.value;

margin = document.frmKitAmount.margin.value / 100;

total = document.frmKitAmount.total.value;

newtotal =(1 + margin) )* base;

document.frmKitAmount.total.value = FormatNumber(newtotal,2,false,true);

}


formatnumber()在别处,它应该工作正常...错误发生在

我将变量base指定为等于表单值的部分

txtTotalKitValue ...这就是.....我是新手,而且我正在使用

代码那是一个已经到位试图添加几个小功能

基本上只是在当前

价格下方的文本框中显示标价价格......
<浏览此页面,请访问 http://67.66。 56.168 / gss / Corporate

并在URL中更改msg = Fast to msg = QLG并按Enter键。转到顶部的任何

黄色标签。我感谢任何回复


< form name =" frmKitAmt">

< input type =" hidden" name =" itemname"

value ="<%= Server.HTMLEncode(objKitList.Name)%>">

< input type = "隐藏"名称= QUOT; imglink" value ="<%= imgLink& objKitList.Image%>">

< input type =" hidden" name =" description"

value ="<%= Server.HTMLEncode(objKitList.Description)%>">

< table border = " 0" CELLSPACING = QUOT 1 QUOT; CELLPADDING = QUOT; 0" width =" 95%">

<%if objKitList.CallForPrice then%>

< input type =" hidden" name =" txtTotalKitValue">

< tr>

< td class = siteNav1TD valign =" middle" colspan =" 3">

< img src =" images / blank.gif">

< / td>< / tr>

<%Else%>

< tr>

< td class = siteNav1TD valign =" middle">

< table width =" 100%">

< tr>

< td colspan =" 3"对齐= QUOT;中心" valign =" middle">

< font face =" Verdana"大小= QUOT; 2英寸color =" #ffffff">< strong> Base

价格:< / strong> < / font>

< / td>

< td>

< font face =" Verdana" size =" 2"

color =" #ffffff">< strong><%= g_currencyString%>& nbsp;<%= FormatNumber(objkitlis

t.price *标记,2)%>< / strong>< / font>

< / td>

< td valign =" middle">

< font face =" Verdana"大小= QUOT; 2英寸color =" #FFFFFF">< strong>您的价格:

<%= g_currencyString%> < / strong>< / font>

< input type =" text" name =" txtTotalKitValue"

value ="<%= FormatNumber(objKitList.Price * Markup,2)%>" size =" 10"

onFocus =" this.blur();">

< / td>

< ; / tr>

< tr>

< td colspan =" 4"对齐= QUOT;中心" valign =" middle">

< font face =" Verdana"大小= QUOT; 2英寸color =" #FFFFFF">< strong>标记:

< / strong>< / font>

< input type =" text"名称= QUOT;余量"值= QUOT; 0" size =" 10"

onblur =" calc_total();">

< / td>

< td valign =" middle">

< font face =" Verdana"大小= QUOT; 2英寸color =" #FFFFFF">< strong>结束价格:

<%= g_currencyString%> < / strong>< / font>

< input type =" text"命名= QUOT;总" value ="<%= FormatNumber(objKitList.Price

* Markup,2)%>" size =" 10">

< / td>

< / tr>

< / table>

< / td>

< td class = siteNav1TD valign =" middle" align =" center"<%if if

objKitList.ClubTotals then%> colspan =" 2"<%End if if%> >

< font face =" Verdana"大小= QUOT 1 QUOT; color =" #FFFFFF">< b>数量:< / b>< br>

< input name =" qty"类型= QUOT;文本"大小= QUOT; 4英寸MAXLENGTH = QUOT; 4英寸value ="<%If

objKitList.Qty> 0然后%><%= objKitList.Qty%><%Else%> 1<%End If%>">< / font>

< / td>

< / tr>

<%End if if%>

< tr>

< td colspan =" 3" height =" 20">< font face =" Verdana" size =" 1">取一个

可打印
此套件的
版本< a href =" javascript :printkit( );"

class =" msn">< strong>点击此处。< / strong>< / a>< / font>< / td>

< / tr>

< tr>

< td>< font face =" verdana" size = 1>< b>项目名称< / b>< / td>

<%如果不是objKitList.ClubTotals而不是objKitList.CallForPrice那么%>

< td align =" center">< font face =" verdana" size = 1>< b> Price< / b>< / td>

<%End if if%>

< td align =" center" ;>< font face =" verdana" size = 1>< b>数量< / b>< / td>

< / tr>

<! -

< / table> - >

< / form>

解决方案

" cwizard" < CW ***** @ giblets.com>写道:

我正在调用这个表单中的一个函数,并且有值设置
但每次调用它时都会遇到运行时错误...
document.frmKitAmount.txtTotalKitValue为null或不是对象...


那么可能是因为document.frmKitAmount.txtTotalKitValue

不存在。实际上是一条信息性错误消息。

base = document.frmKitAmount.txtTotalKitValue.value;


我建议:

var base = document.forms [''frmKitAmount'']。elements [''txtTotalKitValue'']。value;

与所有当前和未来的浏览器保证兼容

(它是W3C DOM的一部分,而表格名称为物业

文件对象是不是。

<%如果objKitList.CallForPrice然后%>
< input type =" hidden" name =" txtTotalKitValue">




我们不能使用服务器端代码。错误发送到客户端的代码



然而,明显的猜测是这个If-test是假的,

所以输入名称为txtTotalKitValue在发送给客户的

页面中不存在。


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL: http://www.infimum.dk/HTML/rasterTriangleDOM.html>

''没有判断的信仰只会降低精神神圣。''


< blockquote>" Lasse Reichstein Nielsen" < lr*@hotpop.com>在消息中写道

新闻:pt ********** @ hotpop.com ...

那么可能是因为文件。 frmKitAmount.txtTotalKitValue
不存在。实际上是一个信息性错误消息。


它怎么可能不存在,表格字段就在那里......如果您看到它的话,它的部分来源,有分配值。我不明白它是怎么回事

null。

我建议:
var base =
document.forms [''frmKitAmount' '] .elements [' 'txtTotalKitValue'']的值。为了保证与所有当前和未来的浏览器的兼容性
(它是W3C DOM的一部分,而将表单名称作为文档对象的属性不是)。


看起来很好,我用过它并没有改变结果。

<%if objKitList.CallForPrice then% >
< input type =" hidden" name =" txtTotalKitValue">



我们不能使用服务器端代码。错误发生在发送给客户端的代码中。
然而,显而易见的猜测是,这个If-test是假的,
所以输入名称为txtTotalKitValue。在发送给客户端的
页面中不存在。




不,这个if-test不是假的,因为套件不是''设置为呼叫

价格


感谢您的尝试!


嘿,


我试图让你的来源更容易:


< html>

< head>

< script>

函数calc_total()

{

base = document.frmKitAmount.txtTotalKitValue.value;

margin = document.frmKitAmount.margin.value / 100;

total = document.frmKitAmount.total.value;

newtotal =(1 + margin)* base;

document.frmKitAmount.total.value = newtotal //插入你的函数:

FormatNumber(newtotal,2 ,false,true);

}

< / script>

< / head>

< ; body>

< form name = frmKitAmount>

基数:<输入t ype = text name = txtTotalKitValue>< br>

保证金:< input type = text name = margin>< br>

总计:< input type = text name = total>< br>

< input type = button onClick = calc_total()value =" Calc">

< / form>

< / body>

< / html>


我认为问题是没有<输入>名字

" frmKitAmount" ;.


但是如果你想用javascript搞砸,只需从

中学习它开始。

制作simpel代码,这样就更容易找到问题....


祝你好运,


AT


I''m calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not an object... the
function is like so:

function calc_total()
{
var x,i,base,margin,total,newmargin,newtotal;
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
total = document.frmKitAmount.total.value;
newtotal = (1 + margin) * base;
document.frmKitAmount.total.value = FormatNumber(newtotal,2,false,true);
}

formatnumber() is elsewhere and it should work fine... the error happens on
the part where i assign the variable base to be equal to the form value
txtTotalKitValue... which is there..... i''m a newbie, and i''m working with
code thats already in place trying to add a couple little functions to
basically just display a marked up price in a text box below a current
price...

to see this page in action please go to http://67.66.56.168/gss/Corporate
and in the URL change msg=Fast to msg=QLG and hit enter. go to any of the
yellow tabs on the top. I appreciate any replies

<form name="frmKitAmt">
<input type="hidden" name="itemname"
value="<%=Server.HTMLEncode(objKitList.Name)%>">
<input type="hidden" name="imglink" value="<%=imgLink & objKitList.Image%>">
<input type="hidden" name="description"
value="<%=Server.HTMLEncode(objKitList.Description )%>">
<table border= "0" cellspacing="1" cellpadding="0" width="95%">
<%If objKitList.CallForPrice then%>
<input type="hidden" name="txtTotalKitValue">
<tr>
<td class=siteNav1TD valign="middle" colspan="3">
<img src="images/blank.gif">
</td></tr>
<%Else%>
<tr>
<td class=siteNav1TD valign="middle">
<table width="100%">
<tr>
<td colspan="3" align="center" valign="middle">
<font face="Verdana" size="2" color="#ffffff"><strong>Base
Price:</strong> </font>
</td>
<td>
<font face="Verdana" size="2"
color="#ffffff"><strong><%=g_currencyString%>&nbsp ;<%=FormatNumber(objkitlis
t.price * Markup,2)%></strong></font>
</td>
<td valign="middle">
<font face="Verdana" size="2" color="#FFFFFF"><strong>Your Price:
<%=g_currencyString%> </strong></font>
<input type="text" name="txtTotalKitValue"
value="<%=FormatNumber(objKitList.Price * Markup,2)%>" size="10"
onFocus="this.blur();">
</td>
</tr>
<tr>
<td colspan="4" align="center" valign="middle">
<font face="Verdana" size="2" color="#FFFFFF"><strong>Markup:
</strong></font>
<input type="text" name="margin" value="0" size="10"
onblur="calc_total();">
</td>
<td valign="middle">
<font face="Verdana" size="2" color="#FFFFFF"><strong>End Price:
<%=g_currencyString%> </strong></font>
<input type="text" name="total" value="<%=FormatNumber(objKitList.Price
* Markup,2)%>" size="10">
</td>
</tr>
</table>
</td>
<td class=siteNav1TD valign="middle" align="center"<%if Not
objKitList.ClubTotals then%>colspan="2"<%End if%> >
<font face="Verdana" size="1" color="#FFFFFF"><b>Quantity :</b><br>
<input name="qty" type="text" size="4" maxlength="4" value="<%If
objKitList.Qty > 0 Then%><%=objKitList.Qty%><%Else%>1<%End If%>"></font>
</td>
</tr>
<%End if%>
<tr>
<td colspan="3" height="20"><font face="Verdana" size="1">To take a
printable
version of this Kit <a href="javascript:printkit();"
class="msn"><strong>Click here.</strong></a></font></td>
</tr>
<tr>
<td><font face="verdana" size=1><b>Item Name</b></td>
<%if Not objKitList.ClubTotals and not objKitList.CallForPrice then%>
<td align="center"><font face="verdana" size=1><b>Price</b></td>
<%End if%>
<td align="center"><font face="verdana" size=1><b>Qty</b></td>
</tr>
<!--
</table>-->
</form>

解决方案

"cwizard" <cw*****@giblets.com> writes:

I''m calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not an object...
Then it is probably because document.frmKitAmount.txtTotalKitValue
doesn''t exist. Actually an informative error message.
base = document.frmKitAmount.txtTotalKitValue.value;
I recommend:
var base = document.forms[''frmKitAmount''].elements[''txtTotalKitValue''].value;
for guaranteed compatability with all current and future browsers
(it''s part of the W3C DOM, whereas having the form name as a property
of the document object isn''t).
<%If objKitList.CallForPrice then%>
<input type="hidden" name="txtTotalKitValue">



We can''t use server-side code for anything. The error is in the code
that is sent to the client!
However, the obvious guess would be that this If-test is false,
so the input with name "txtTotalKitValue" doesn''t exist in the
page that is sent to the client.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''


"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:pt**********@hotpop.com...

Then it is probably because document.frmKitAmount.txtTotalKitValue
doesn''t exist. Actually an informative error message.
How can it not exist, the form field is there... its part of the source if
you look at it, there are values assigned.. I don''t understand how it is
null.
I recommend:
var base = document.forms[''frmKitAmount''].elements[''txtTotalKitValue''].value; for guaranteed compatability with all current and future browsers
(it''s part of the W3C DOM, whereas having the form name as a property
of the document object isn''t).
That looks fine, I used that and it didn''t change the results.

<%If objKitList.CallForPrice then%>
<input type="hidden" name="txtTotalKitValue">



We can''t use server-side code for anything. The error is in the code
that is sent to the client!
However, the obvious guess would be that this If-test is false,
so the input with name "txtTotalKitValue" doesn''t exist in the
page that is sent to the client.



No, this if-test is not false because the kit isn''t set up as "Call for
Price"

Thanks for trying!


Hey,

I''ve tried to make you''re source a little easier:

<html>
<head>
<script>
function calc_total()
{
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
total = document.frmKitAmount.total.value;
newtotal = (1 + margin) * base;
document.frmKitAmount.total.value = newtotal //insert your function:
FormatNumber(newtotal,2,false,true);
}
</script>
</head>
<body>
<form name=frmKitAmount>
Base : <input type=text name=txtTotalKitValue><br>
Margin : <input type=text name=margin><br>
Total: <input type=text name=total><br>
<input type=button onClick=calc_total() value="Calc">
</form>
</body>
</html>

The problem I think is that there isn''t a <input> with the name
"frmKitAmount".

But if you wanne fool around with javascript, just learn it from the
beginning.
Make simpel code, so it''s easier to find problems....

good luck,

A.T.


这篇关于value是null还是不是对象,但是它定义了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆