[英]JS handling drop down boxes
i have this script which allows the users to select from Dropdown 1, and it will fill Dropdown 2 with values. 我有这个脚本,允许用户从下拉列表1中选择,它将使用值填充下拉列表2。 THOUGH the problem here is that once it fills, the original "item" called "-- Välj län först --" disappears, which i do not want it to do.
这里的问题是,一旦它填满,原来的“项目”称为“ - Väljlänförst - ”就会消失,我不想这样做。 I just want the new values to fill up under it.
我只想让新值填满它。 Could someone take a look at the code i supply below and see if there is an easy fix for this?
有人可以看看我在下面提供的代码,看看有一个简单的解决方案吗?
Thanks in advance. 提前致谢。
Try this 尝试这个
function showSubKommun(subCat,selectObj){
selectObj.length=kommun[subCat].length+1;
selectObj[0].text=kommun[0][0];
selectObj[0].value=kommun[0][0];
for(var n=0;n<kommun[subCat].length;n++){
selectObj[n+1].text=kommun[subCat][n];
selectObj[n+1].value=kommun[subCat][n];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.