<script> var mainlist=document.form.seleField; //var valuelist=document.form.seleValue //var value=new Array(); var parent = document.getElementById("id1"); var value=[] value[0]="" value[1]=["Monthly|M", "Bi-Weekly|BW", "Weekly|W", "Daily|D"] value[2]=["Monday|1", "Tuesday|2", "Wednesday|3", "Thursday|4", "Friday|5", "Saturday|6", "Sunday|7"] value[3]=["> 100|100","> 300|300", "> 500|500", "> 700|700", "> 1000|1000", "> 1500|1500", "> 2000|2000" , "> 5000|5000"] /* function updatevalue(selectedvaluegroup){ valuelist.options.length=0 if (selectedvaluegroup>0){ for (i=0; i<value[selectedvaluegroup].length; i++) valuelist.options[valuelist.options.length]=new Option(value[selectedvaluegroup][i].split("|")[0], value[selectedvaluegroup][i].split("|")[1]) } } */ function updatevalue(selectedvaluegroup){ parent.innerHTML = ""; if(selectedvaluegroup ==2){ for (var i=0; i<value[selectedvaluegroup].length; i++){ var chkbox = document.createElement("input"); chkbox.type = "checkbox"; chkbox.name = "day[]"; chkbox.value = value[selectedvaluegroup][i].split("|")[1]; parent.appendChild(chkbox); var text = document.createElement("span"); text.innerHTML = value[selectedvaluegroup][i].split("|")[0]; parent.appendChild(text); } }
1 回答
HUWWW
TA贡献1874条经验 获得超12个赞
请检查以下示例。希望对您有所帮助
var foo = document.getElementById('foo');
var bar = document.getElementById('bar');
var valueBtn = document.getElementById('valueBtn');
foo.addEventListener('change', function () {
bar.value = this.options[this.selectedIndex].value;
}, true);
valueBtn.addEventListener('click', function () {
console.log(bar.value)
}, true);
<select id="foo">
<option>select option</option>
<option>a</option>
<option>b</option>
</select>
<input style="display:none " type="text" id="bar">
<input type="button" id="valueBtn" value="Click and check console">
- 1 回答
- 0 关注
- 79 浏览
添加回答
举报
0/150
提交
取消