Javascript 2 comboxbox select如何工作并显示相应的iframe?

Javascript 2 comboxbox select如何工作并显示相应的iframe?,javascript,html,Javascript,Html,我试图在网页上做2个组合框 让所述国家选项人选择“中国”,第二个组合框将列出所有省份,之后如果用户选择“江苏”为例,将在第二个组合框下方打开一个专用iframe 知道怎么做吗 <script type="text/javascript"> /* Triple Combo Script Credit By Philip M: http://www.codingforums.com/member.php?u=186 Visit http://javasc

我试图在网页上做2个组合框

让所述国家选项人选择“中国”,第二个组合框将列出所有省份,之后如果用户选择“江苏”为例,将在第二个组合框下方打开一个专用iframe

知道怎么做吗

<script type="text/javascript">

    /*
    Triple Combo Script Credit
    By Philip M: http://www.codingforums.com/member.php?u=186
    Visit http://javascriptkit.com for this and over 400+ other scripts
    */

    var categories = [];
    categories["startList"] = ["China","US"]
    categories["China"] = ["ANHUI","JIANGSU"];
    categories["US"] = ["Alabama","New york"];

    var nLists = 2; // number of select lists in the set

    function fillSelect(currCat,currList){
        var step = Number(currList.name.replace(/\D/g,""));
        for (i=step; i<nLists+1; i++) {
            document.forms['tripleplay']['List'+i].length = 1;
            document.forms['tripleplay']['List'+i].selectedIndex = 0;
        }
        var nCat = categories[currCat];
        for (each in nCat) {
            var nOption = document.createElement('option'); 
            var nData = document.createTextNode(nCat[each]); 
            nOption.setAttribute('value',nCat[each]); 
            nOption.appendChild(nData); 
            currList.appendChild(nOption); 

        }

    }

    function getValue(L2, L1) {

        <!-- alert("Your selection was:- \n" + L1 + "\n" + L2);-->
        document.getElementById("lname").value= L1 + "\n" + L2;
    }


    function init() {
        fillSelect('startList',document.forms['tripleplay']['List1'])
    }

    navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);           

</script>

/*
三重组合脚本信用
菲利普M:http://www.codingforums.com/member.php?u=186
参观http://javascriptkit.com 对于此脚本和400多个其他脚本
*/
var类别=[];
类别[“震惊者”]=“中国”、“美国”]
类别[“中国”]=[“安徽”、“江苏”];
类别[“美国”]=“阿拉巴马州”、“纽约州”];
变量nLists=2;//集合中的选择列表数
函数fillSelect(currCat,currList){
var step=Number(currList.name.replace(/\D/g,“”);
for(i=步骤;i


我需要一个iframe语句而不是textarea属性这里是一个基本示例

var nList1=document.querySelector('select[name=“List1”]”),
nList2=document.querySelector('select[name=“List2”]”),
myFrame=document.getElementById('myFrame'),
类别=[“中国”、“美国”],
内容={
中国:[“安徽”、“江苏”],
美国:[“阿拉巴马”、“纽约”]
}
类别。forEach(功能(类别){
var option=document.createElement('option');
option.value=option.textContent=category;
nList1.追加子项(可选);
});
nList1.addEventListener('change',函数(evt){
var目标=evt.target,
value=target.value,
选项=nList2.options,
内容=内容[值];
myFrame.src='';
nList2.selectedIndex=0;
while(options.length>1){
nList2.removeChild(选项[1]);
}
如果(内容){
content.forEach(函数(元素){
var option=document.createElement('option');
option.value=option.textContent=element;
nList2.追加子项(可选);
});
}
},假);
nList2.addEventListener('change',函数(evt){
if(evt.target.selectedIndex){
myFrame.src='/';
}否则{
myFrame.src='';
}
},false);
。下拉列表{
显示:块;
}
#我的框架{
边缘顶部:1米;
宽度:100%
}
国家/地区选择
类别:
挑选
内容:
挑选

我需要一个示例如何实现这一点,因为我只有一个组合框,正在寻找一个示例,第二个组合框在iframe之后将如何工作,你有一个示例吗?向我们展示你到目前为止的情况。我使用上述JS,但我无法找出如何制作iframe一旦选择了最后一个第二个组合框值,我删除了一些国家名称,然后省,使其简单易读。将
替换为
,然后您可以方便地引用它并执行所需操作。问题是如何分配不同的iframe页面?这就像如果我选择江苏,例如将使用相应的html触发iframe1,选择安徽将使用指定的iframe触发另一个iframepageHi Xotic750,这里的问题您的选择只有2个iframe选择我们如何添加更多的iframe,考虑到将来我的省组合列表将更多,每个省都将有自己的iframe属性窗口将条件更改为适合您的列表
if(evt.target.selectedIndex){myFrame.src='/';
谢谢分享:)
<span class="favorBOfont">Country Selection</span><p>&nbsp;</p>

<form name="tripleplay" action="">
    Category: 
    <select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
        <option selected>Make a selection</option>
    </select>
    &nbsp;

    <p>&nbsp;</p>
    <p>
        Content:
    <select name='List2' onchange="getValue(this.value, this.form['List1'].value)">
        <option selected>Make a selection</option>
    </select>
        <!-- onchange="fillSelect(this.value,this.form['List3'])" -->


    </p>

</form>
&nbsp;<p>&nbsp;</p>
<p>
    <textarea rows="8" cols="88" id="lname" name="lname" size="30" height="30" readonly></textarea>
</p>
<div></div>