选择标签更改时多个参数不起作用

时间:2018-09-25 11:53:36

标签: javascript jquery html javascript-events

我正在将id作为选择标签的onchange属性内的第二个参数传递

struct QuizQu: Codable {
    var ques_id: String?
    var their_answer: String?
}

let questions = [
    QuizQu(ques_id: "1", their_answer: "2"),
    QuizQu(ques_id: "2", their_answer: "2"),
    QuizQu(ques_id: "3", their_answer: "1"),
    QuizQu(ques_id: "4", their_answer: "4"),
    QuizQu(ques_id: "5", their_answer: "3")
]

do {
    let encoded = try JSONEncoder().encode(questions)
    print(String(bytes: encoded, encoding: .utf8))
} catch {
    print(error)
}

当我从select标记中选择任何内容时,它将在fetchAllStops()函数中引发错误消息。

请帮助!!!

1 个答案:

答案 0 :(得分:0)

用下面的代码替换您的代码,然后尝试

  "<td class='col-sm-2'>" + '<select id="route_' + id + '" name="route' + id + '" type="text" class="form-control validate-required" onchange="fetchAllStops("'+this.value+'","' + id + '"")"> </select>' + "</td>"