如何解决Uncaught ReferenceError:populate没有定义?

时间:2016-05-26 19:40:58

标签: javascript node.js html5 ionic-framework

这是我的代码。帮我解决这个家伙。感谢所有答案。

代码:



<script type="text/javascript">
  function populate(s1, s2) {
    var s1 = document.getElementById(s1);
    var s2 = document.getElementById(s2);
    s2.innerHTML = "";
    if (s1.value == "Futsal") {
      var optionArray = ["|", "court a| Court A", "court b|Court B", "court c|Court C"];
    }
    for (var option in optionArray) {
      var pair = optionArray[option].split("|");
      var newOption = document.createElement("option");
      newOption.value = pair[0];
      newOption.innerHTML = pair[1];
      s2.options.add(newOption);
    }
  }
</script>
<label class="item item-select">
  <span class="input-label">Sports</span>
  <select id="sport" name="sport" onchange="populate(this.id,'Court')" ;>
    <option value=""></option>
    <option value="Futsal">Futsal</option>
    <option value="Badminton">Badminton</option>
  </select>
</label>
<label class="item item-select">
  <span class="input-label">Court</span>
  <select id="Court" name="Court"></select>
&#13;
&#13;
&#13;

这是错误ReferenceError:populate未定义

0 个答案:

没有答案