简体   繁体   中英

why java script dont work?

i have this code but im facing an error in chrome that the load_new_content_dr is not defined...

<html>
<head>

<script lang="javascript" src="http://code.jquery.com/jquery-latest.js">
  $(document).ready(function(){

    $("#Dr_name").change(load_new_content_dr()); 
    $("#day").change(load_new_content_day());
});
function load_new_content_dr(){
     var selected_option_value=$("#Dr_name option:selected").val();

     $.post("_add_reservasion.php", {option_value: selected_option_value},
         function(data){ 
              $("#day").html(data);
              alert(data);
       }
     );

     $.post("__add_reservasion.php",
      function(data){
        $("#time").html(data);
        alert(data);

      }
    );
}

function load_new_content_day(){
      var selected_day = $("#day option:selected").val();
  $.post("__add_reservasion.php", {selected_day:selected_day},
    function(data){
      $("#time").html(data);
      alert(data);

    }
  );
}

  </script>
</head>
  <body>
 ...

some codes for connecting database and other stiffs...


...
<!--======================doctore name=========================-->
<p>doctor name:</p>
      <select name="Dr_name" id = "Dr_name" form="new" onchange="load_new_content_dr()">
        <option value="null"></option>
        <?php
          while($row = mysqli_fetch_array($table))
          {
            $name = $row["name"];
            if(isset($_POST["Dr_name"]) && $_POST["Dr_name"] == $name)
              echo "<option value =$name selected>$name</option>";
            else
              echo "<option value =$name>$name</option>";

          }
        ?>

      </select><br><br><br>
<!--=========== day===============\\-->
<p>reservation day:</p>
<select name="day" id="day" form="new" onchange="load_new_content_day()"></select><br><br><br>
<!--hour-->
<p>time:</p>
      <select name="time" id = "time" form = "new"></select><br><br>


<input type="submit" value="save">
<input type="submit" name="cancel" value="cancel">
    </form>
  </body>
</html>

it seems that java script codes don't work because at first when the page loads they should make some change and they don't :(

If you specify src attribute of the script tag, then its text content is ignored. You should use two script tags instead:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
  // ...
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM