0

このスクリプトを機能させようとしています:

<script type="text/javascript">
          $(document).ready(function () {
              $("#councilsel").change(function () {
                  var val = $(this).val();
                  if (val == "manlysel") {
                      $("#suburbsel").html("<option value='test'>item1: test 1</option><option value='test2'>item1: test 2</option>");
                  } else if (val == "warringahsel") {
                      $("#suburbsel").html("<option value='Beacon Hill'>Beacon Hill</option><option value='Brookvale'>Brookvale</option><option value='Collaroy'>Collaroy</option><option value='Collaroy Plateau'>Collaroy Plateau</option><option value='Cottage Point'>Cottage Point</option><option value='Cromer'>Cromer</option><option value='Curl Curl'>Curl Curl</option><option value='Dee Why'>Dee Why</option><option value='Freshwater'>Freshwater</option><option value='Ingleside'>Ingleside</option><option value='Manly Vale'>Manly Vale</option><option value='Narrabeen'>Narrabeen</option><option value='Narraweena'>Narraweena</option><option value='North Balgowlah'>North Balgowlah</option><option value='North Curl Curl'>North Curl Curl</option><option value='North Manly'>North Manly</option><option value='Queenscliff'>Queenscliff</option><option value='Wheeler Heights'>Wheeler Heights</option>");
                  } else if (val == "pittwatersel") {
                      $("#suburbsel").html("<option value='test'>item3: test 1</option><option value='test2'>item3: test 2</option>");
                  }
              });
          });
</script>

このhtmlフォームで

<select name="councilsel" id="councilsel">
<option value="selopt" selected="selected">--select an option</option>
<option value="manlysel">Manly Council</option>
<option value="warringahsel">Warringah Council</option>
<option value="pittwatersel">Pittwater Council</option>

</select>
<select name="suburbsel" size="1" id="suburbsel">
<option value="">--select a option--</option>
</select>

しかし、表示しようとするとこのエラーが発生し続けます

<script type="text/javascript">
          $(document).ready(function () {
Uncaught ReferenceError: $ is not defined
              $("#councilsel").change(function () {
                  var val = $(this).val();
                  if (val == "manlysel") {
                      $("#suburbsel").html("<option value='test'>item1: test 1</option><option value='test2'>item1: test 2</option>");
                  } else if (val == "warringahsel") {
                      $("#suburbsel").html("<option value='Beacon Hill'>Beacon Hill</option><option value='Brookvale'>Brookvale</option><option value='Collaroy'>Collaroy</option><option value='Collaroy Plateau'>Collaroy Plateau</option><option value='Cottage Point'>Cottage Point</option><option value='Cromer'>Cromer</option><option value='Curl Curl'>Curl Curl</option><option value='Dee Why'>Dee Why</option><option value='Freshwater'>Freshwater</option><option value='Ingleside'>Ingleside</option><option value='Manly Vale'>Manly Vale</option><option value='Narrabeen'>Narrabeen</option><option value='Narraweena'>Narraweena</option><option value='North Balgowlah'>North Balgowlah</option><option value='North Curl Curl'>North Curl Curl</option><option value='North Manly'>North Manly</option><option value='Queenscliff'>Queenscliff</option><option value='Wheeler Heights'>Wheeler Heights</option>");
                  } else if (val == "pittwatersel") {
                      $("#suburbsel").html("<option value='test'>item3: test 1</option><option value='test2'>item3: test 2</option>");
                  }
              });
          });
</script>

これがすべきことです:

http://jsfiddle.net/HAkkF/embedded/result/

ページへのリンクは次のとおりです。

http://fin.awesomesights.com/submit.php

4

1 に答える 1

6

ページに入れ忘れましjQueryた。

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
于 2013-05-11T14:39:14.873 に答える