嘿嘿,我想要 2 个内容相似的下拉菜单。只要版本 2 不存在,版本 1 就可以工作。一旦我包含 version2,只有 version2 的输出被正确识别,并且 version1 的输出显示为“未定义”。谁能帮我?
Version1
*html
<select id="Store">
<option value="noSelection">Snippet</option>
<option value="test1">Test1</option>
<option value="test2">Test2</option>
</select>
<span id="Adress"></span>
*script
var Store = document.getElementById("Store"),
Adress = document.getElementById("Adress"),
stores = {
noSelection: "",
Test1: "Test1",
Test2: "Test2",
}```
Store.onchange = function(){
snippetMobile.innerHTML = stores[this.value];
}
Version2
*html
<select id="Gas">
<option value="noSelection">Snippet</option>
<option value="test1">Test1</option>
<option value="test2">Test2</option>
</select>
<span id="Number"></span>
*script
var Gas = document.getElementById("Gas"),
Number = document.getElementById("Number"),
stores = {
noSelection: "",
Test3: "Test3",
Test4: "Test4",
}
Gas.onchange = function(){
Number.innerHTML = stores[this.value];
}
倚天杖
相关分类