Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

怎么在s.onchange里取得外层index?

        function callBack() {
            if(xhr.status == 200 || xhr.status == 304) {
                if(xhr.readyState == 4) {
                    var data = JSON.parse(xhr.responseText)["城市代码"];
                    var index = 0;
                    for(var i = 0; i < data.length; i++) {
                        index = i;
                        s.innerHTML += ("<option>" + data[i]["省"] + "</option>")
                        s.onchange = function(i) {
                        console.log(i)
                        i = i.target
                        x.innerHTML += ("<option>" + "请选择" + "</option>")
                            if(s.value == i.value) {
                                i = i.value
                                console.log(i)
                                x.innerHTML += ("<option>" +  + "</option>")
                                
//                                for(var m = 0; m < data[j]["市"].length; m++) {
//                                    x.innerHTML += ("<option>" + data[j]["市"][m]["市名"] + "</option>")
//                                    console.log(data[j]["市"][m]["市名"])
//                                }
                            }

                        }
                    }
                }
            }
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...