如何存储我从隐藏字段中的下拉和复选框中选择的值?

http://img2.mukewang.com/62da679e000123df12751024.jpg

http://img4.mukewang.com/62da67a8000174db12821020.jpg

<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);

                

                

            }

        }

        


当年话下
浏览 80回答 1
1回答

HUWWW

请检查以下示例。希望对您有所帮助var foo = document.getElementById('foo');var bar = document.getElementById('bar');var valueBtn = document.getElementById('valueBtn');foo.addEventListener('change', function () {&nbsp; &nbsp; bar.value = this.options[this.selectedIndex].value;}, true);valueBtn.addEventListener('click', function () {&nbsp; &nbsp; console.log(bar.value)}, true);<select id="foo">&nbsp; &nbsp; <option>select option</option>&nbsp; &nbsp; <option>a</option>&nbsp; &nbsp; <option>b</option></select><input style="display:none " type="text" id="bar"><input type="button" id="valueBtn" value="Click and check console">
打开App,查看更多内容
随时随地看视频慕课网APP