开发者

on change select load another select options using jquery load

开发者 https://www.devze.com 2023-02-12 23:26 出处:网络
Here is my Javascript which is below a select box wi开发者_如何转开发th the id of \"course_name\" and a div with an id of \"dates\"

Here is my Javascript which is below a select box wi开发者_如何转开发th the id of "course_name" and a div with an id of "dates"

<script>
$('#course_name').change(function() {
    url = "date_range.php?courseID=".$('#course_name').val();
  $("#dates").load(url)
});

</script>

when i call date_range.php?courseID=1 through my browser it displays the dates but the code above is not loading.


url = "date_range.php?courseID="+$('#course_name').val();

or better still,

url = "date_range.php?courseID="+parseInt($('#course_name').val());

the second one will always return a number so it's either 0 (zero) or above, if the #course_name value is a non numeric number it would return zero, otherwise returns the number... this is especially useful when you want to validate the value on the server.

0

精彩评论

暂无评论...
验证码 换一张
取 消