gpt4 book ai didi

javascript - 选择下拉列表在 IE9 中扩展很长

转载 作者:行者123 更新时间:2023-11-28 11:19:39 24 4
gpt4 key购买 nike

我正在使用 ajax 调用动态填充值以选择下拉列表。
我的代码在 IE8 中运行良好,但在 IE9 中运行不正常。选择下拉列表未正确显示。它正在扩展。

这里是我的代码片段:

if(xmlHttpReq.status==200)
{
var acaComplRulesDtls=xmlHttpReq.responseText;
//resetting individualstoApplyComplianceRules dropdown as blank
document.getElementById("individualstoApplyComplianceRules").innerHTML="";
var spiltedACACompRules=acaComplRulesDtls.split("###");
if(spiltedACACompRules.length==2){
var indvNames=spiltedACACompRules[0];
var indvNumbers=spiltedACACompRules[1];
var spiltedIndvNames=indvNames.split("~~");
var spiltedindvNumbers=indvNumbers.split("^^");
var namelen=spiltedIndvNames.length;
var numberlen=spiltedindvNumbers.length;
//checking names & numbers length same or not
if(namelen==numberlen){
var selectField=document.getElementById("individualstoApplyComplianceRules");
for(var i=0; i<namelen-1; i++){
var optionField = document.createElement("OPTION");
optionField.text = spiltedIndvNames[i];
optionField.value = spiltedindvNumbers[i]
selectField.options.add(optionField);
} //for loop ends here
}
} //if

谁能帮我解决这个浏览器兼容性问题?

提前致谢..

screen shot http://imageshack.com/a/img811/177/bgzy.png

最佳答案

我找到了解决方案。我的问题已解决。ajax 响应文本包含许多空格。

我使用 replace(/^\s+|\s+$/g,'') Java 脚本方法删除了空格。现在选择下拉菜单显示正常。

感谢大家!!!祝你有美好的一天!!!

关于javascript - 选择下拉列表在 IE9 中扩展很长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21597089/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com