SCRIPT5007:无法获取未定义或空引用的属性“值" [英] SCRIPT5007: Unable to get property 'value' of undefined or null reference

查看:1353
本文介绍了SCRIPT5007:无法获取未定义或空引用的属性“值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML表单,该表单在IE10中似乎不起作用.单击转到按钮上的调试时,调试返回:"SCRIPT5007:无法获取未定义或空引用的属性'值'" 我已在HTML页面中添加了此标签

I have a html form that appears not to be functional in IE10. when click on go button debugging returns:"SCRIPT5007: Unable to get property 'value' of undefined or null reference" I have added this tag in my html page

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />.

html包含myform中频率的下拉菜单选项.在下拉菜单中选择任何选项后,我将在javascript函数下方调用.

html contains dropdown menu option for frequency in myform.After selecting any option in dropdown i am calling below javascript function.

function chooseFreqMenu(freqValues,freqTexts)
{
    var cf = document.myform;
    var freq1=document.myform.freq.value; // freq1="d"
    alert(freq1);// displaying freq1 value is "d" (ex:selected 'd' in html dropdown)
// checking some condition for freqValues.
    for(var i=4;i<freqValues.length;i++)
            selectStr += '<option value="'+freqValues[i]+'">'+freqTexts[i]+'\n';
    }
    selectStr += '</select>';
    // Assinging the selectedStr to innerHTML. After this statement i am getting empty for freq1 value. 
    //Its working fine in IE<10 browsers
    document.all.freqSel.innerHTML = selectStr; 
    alert(freq1); // displaying freq1 value is empty.
}   

在将myform发送到choiceFreqmenu之前,myform包含freq value ="d"(假设我在下拉菜单中选择了'd') 在上面的函数之后,myform不包含freq值. 在上述函数将myform传递给buildQueryStr之后.

Before sending myform to chooseFreqmenu, myform contains freq value="d"(assume i selected 'd' in dropdown) After the above function myform doesn't contain freq value. After the above function passing myform to buildQueryStr.

function buildQueryStr(myform)
{

var freq=myform.freq.value; //Getting an error SCRIPT5007: Unable to get property 'value' of undefined or null reference in this line

//some other fields.

}

如何解决此问题?

有什么建议吗??预先感谢.

Any suggestions?? Thanks in Advance.

推荐答案

我认为IE 10不再支持 myform.freq.value 语法的访问元素.

I don't think IE 10 supports acessing elements with the myform.freq.value syntax anymore.

访问Elements的标准方法(包括IE在内的所有浏览器均支持)使用 document.getElementById 函数

The standard way of accessing Elements (this is supported in all browsers including IE) is with the document.getElementById function

function buildQueryStr(myform) {

    //var freq=myform.freq.value; //Getting an error SCRIPT5007: Unable to get property 'value' of undefined or null reference in this line
    var freq=document.getElementById("freq").value;

    //some other fields.
}

这篇关于SCRIPT5007:无法获取未定义或空引用的属性“值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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