列表框的页面加载中未包含值 [英] Value is not coming in page load from list box
问题描述
大家好,
我正在尝试从页面加载时的列表框中获取值.然后使用XmlHttp Header从Java Script填充列表框中的值.
从Ajax,我可以从服务器端获取列表框中的值,但我也无法在页面加载时获取列表框的值.
这是xml Http标头的代码,其中值在响应中的列表框中更新:
Hi All,
I am trying to get the value from a list box on page load. And the values in list box are populating from Java Script using XmlHttp Header.
From Ajax I am able to get Values in list box from server side but I am nor getting the list box value on page load.
Here is the code for xml Http header where the values are updated in list box from response :
var customerList = document.getElementById("ListBox");
for (var count = customerList.options.length-1; count > -1; count--)
{
customerList.options[count] = null;
}
var customerNodes = customerNode.getElementsByTagName(''customer_name'');
var textValue;
var optionItem;
for (var count = 0; count < customerNodes.length; count++)
{
textValue = GetInnerText(customerNodes[count]);
optionItem = new Option( textValue, textValue, false, false);
customerList.options.add(optionItem);
}
请帮助我解决我的问题.感谢advacne!
问候,
Divya
Please help me in resolving my problem. Thanks in advacne !
Regards,
Divya
推荐答案
尝试类似的方法:
Try something like this:
var typeElem = responseElem[0].getElementsByTagName("Table");
for (var i = 0; i <typeElem.length;i++)
{
var textNode = document.createTextNode(typeElem[i].firstChild.text);
AppendToSelect(typeElem[i].lastChild.text, textNode);
}
function AppendToSelect(value, content)
{
var opt;
customerList = window.document.getElementById("ListBox");
opt = document.createElement("option");
opt.value = value;
opt.appendChild(content);
customerList.appendChild(opt);
}
您应该能够获得回发期间选择的值.
You should be able to get the values selected during postback.
您好,
感谢您的答复,但在页面加载时我仍然无法从列表框中获取值,并且给出了错误提示对象设置为空引用".
问候,
DIvya
Hi,
Thanks for your response but I am still not able to get the values from list box at page load and it gives error stating "Object set to null reference".
Regards,
DIvya
我得到了解决方案:
http://forums.devshed.com/net-development-87/problem-with-a-listbox-populated-from-javascript-184068.html
这对我有用! :)
谢谢你的时间.
问候,
Divya
I got the solution :
http://forums.devshed.com/net-development-87/problem-with-a-listbox-populated-from-javascript-184068.html
This Worked for me ! :)
Thanks for your time.
Regards,
Divya
这篇关于列表框的页面加载中未包含值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!