本文介绍了列表框的页面加载中未包含值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试从页面加载时的列表框中获取值.然后使用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
推荐答案
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.
这篇关于列表框的页面加载中未包含值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!