这件事困扰了我一整天,如果有人可以帮助我,我将不胜感激。
if(aaid) {
var num_one = aaid;
var radioBox = document.getElementsByName('used_dealer_before');
for (i = 0; i < radioBox.length; i++) {
if(num_one) {
radioBox[i].checked = true; //this auto checks the box
}
}
radioBox.onchange=function(){
document.getElementById("previous_dealer").value=num_one; //this auto selects the value from the dropdown
}
}
如果存在变量(aaid),上面的函数会自动检查单选框,一旦选中此框,另一个脚本文件(我无权访问;长篇大论)中的另一个函数会显示一个下拉菜单。MY 脚本的下一部分会在下拉列表中自动选择一个值。此脚本有效并且已在本地测试。但是,当我将它上传到服务器时,它不再执行脚本的第二部分。我怀疑是因为该函数已经执行,当页面尚未完成呈现下拉值时。因此,任何人都可以向我解释如何使用 JavaScript 等待下拉菜单出现,然后再继续执行脚本?
我应该延迟该功能吗?我不能使用 jQuery,我必须使用 JavaScript。