i'd like to call a jquery function from php. I tried this way, but the jquery functions are not called.
jq.action.js
$(function() {
  $("#reset" ).click(function(e){       
    e.preventDefault();
    reset_fields();
  });
  function reset_fields(){
    $(":input").prop('selectedIndex', 0);
  }
  function error_msg(){
    alert("Error");
  }
});
index.php
<script type='text/javascript' src='jquery-1.11.1.min.js'></script>
<script type='text/javascript' src='jq.action.js'></script> 
<?php
if ($_POST['id'] == '1') {
       echo '<script>reset_fields();</script>';
} else {
       echo '<script>error_msg();</script>';
}
?>
ReferenceError: reset_fields is not defined
how can I call from php the functions inside jquery? thanks!
 
     
     
    