本文介绍了消息'是null或不是对象'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我的下拉列表''cboUnitTypes''是在另一个

dropdownlist1的基础上填充的,我必须对''进行检查' 'cboUnitTypes''如

if(cboUnitTypes [cboUnitTypes.selectedindex] .value == 0)return false;现在

问题是;当我看到视图源,firefox和IE显示

不同的源代码时,我面临一个错误描述''cbounittypes是null或

不是对象'。'firefox正在显示对。但IE没有。什么'

原因??


-----使用firefox的viewsource

:return

ConfirmDeleteImage(); __ doPostBack(''cboUnitTypes'','''')"

language = QUOT; JavaScript的" id =" cboUnitTypes"

class =" TextFieldNormalForProperty">

< option selected =" selected" value =" 0">< / option>

< option value =" 396"> 34< / option>

< option value = " 405">没有< / option>

< option value =" 412"> test< / option>


< /选择>


-----使用IE浏览器


< select name =" cboUnitTypes" onchange =" javascript :return

ConfirmDeleteImage(); __ doPostBack(''cboUnitTypes'','''')"

language = QUOT; JavaScript的" id =" cboUnitTypes"

class =" TextFieldNormalForProperty" style =" width:200px;">


< / select>

hi all,

my dropdownlist ''cboUnitTypes'' is populating on the base of another
dropdownlist1, i have to apply a check on ''cboUnitTypes'' like
if(cboUnitTypes[cboUnitTypes.selectedindex].value==0)return false; now
problem is; i face an error describing ''cbounittypes is either null or
not an object'' when i see view source, firefox and IE showing
different source code.firefox is showing right. but IE not. what''s
reason??

----- viewsource using firefox

<select name="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack(''cboUnitTypes'','' '')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty">
<option selected="selected" value="0"></option>
<option value="396">34</option>
<option value="405">nothing</option>
<option value="412">test</option>

</select>

----- viewsource using IE

<select name="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack(''cboUnitTypes'','' '')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">

</select>

推荐答案



语言不是SELECT元素的属性。这应该被删除

language is not a property of a SELECT element. This should be removed



您的页面是否进行任何DOM操作?更具体地说,是Javascript动态生成的

选项元素吗?


如果是这样,那就是原因。当您使用MSIE查看源代码时,您只能看到服务器返回原始GET请求的来源




至于您的错误'我看到了。如果您发布了生成此错误的Javascript,那么我们将有更好的机会帮助您

Does your page do any DOM manipulation? More specifically, are the
option elements generated on the fly by Javascript?

If so, that''s why. When you view source with MSIE, you only get to see
the source that the server returned to your original GET request.

As for the error you''re seeing. If you post the Javascript that''s
generating this error, we''ll have a better chance of helping you




- -

但是我不能在IE中输入下拉列表值。

这里是完整的信息。


< select名称= QUOT; cboUnitTypes" onchange =" javascript :return

ConfirmDeleteImage(); __ doPostBack(''cboUnitTypes'','''')"

language = QUOT; JavaScript的" id =" cboUnitTypes"

class =" TextFieldNormalForProperty" style =" width:200px;">


< / select>

< input name =" lblHiddenUnitType" ID = QUOT; lblHiddenUnitType" type =" hidden"

size =" 14" />

< script language =''javascript''>

函数ConfirmDeleteImage()

{

var result;

var cbo = document.getElementById(''cboUnitTypes'');

if(cbo.options.length< = 0)返回false;


if(document.all [''lblHiddenUnitType'']。value!=''0''||

document.all [''lblHiddenUnitType ''] .value> = 0 ||

document.all [''lblHiddenUnitType'']。value!= null ||

document.all ['' lblHiddenUnitType'']。value!='''')


{

result = confirm('''现有图片将被替换为新的

ones.你想继续吗?'');

}

if(result == false)

{

document.all [''cboUnitTypes'']。onchange = null;

document.all [''cboUnitTypes'']。value =

document.all [''lblHiddenUnitType'']。value;

document.all [''cboUnitTypes'']。onchange = ConfirmDeleteImage;

}

else

{

document.all [''cboUnitTypes'']。onchange = null;

document.all [''lblHiddenUnitType'']。value =

document.all [''cboUnitTypes'' ] .value;

document.all [''cboUnitTypes'']。onchange = ConfirmDeleteImage;

__doPostBack(''cboUnitTypes'','''');

}

返回结果;

}

< / script>

- ----

我正在为IE工作,而不是为Firefox工作。

----
but i can''t my dropdownlist values in IE.
here is complete info.

<select name="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack(''cboUnitTypes'','' '')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">

</select>
<input name="lblHiddenUnitType" id="lblHiddenUnitType" type="hidden"
size="14" />
<script language=''javascript''>
function ConfirmDeleteImage()
{
var result;
var cbo = document.getElementById(''cboUnitTypes'');
if (cbo.options.length <= 0) return false;

if (document.all[''lblHiddenUnitType''].value != ''0''||
document.all[''lblHiddenUnitType''].value >= 0 ||
document.all[''lblHiddenUnitType''].value != null||
document.all[''lblHiddenUnitType''].value != '''')

{
result= confirm(''Existing Image(s) will be replaced with the new
ones.Do you want to continue?'');
}
if(result == false)
{
document.all[''cboUnitTypes''].onchange = null;
document.all[''cboUnitTypes''].value =
document.all[''lblHiddenUnitType''].value;
document.all[''cboUnitTypes''].onchange = ConfirmDeleteImage;
}
else
{
document.all[''cboUnitTypes''].onchange = null;
document.all[''lblHiddenUnitType''].value =
document.all[''cboUnitTypes''].value;
document.all[''cboUnitTypes''].onchange = ConfirmDeleteImage;
__doPostBack(''cboUnitTypes'','''');
}
return result;
}
</script>
-----
I am working for IE, not for Firefox.



这篇关于消息'是null或不是对象'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 13:39