javascript / jQuery functions not firing -


updated:

thanks feedback. did have multiple faults in code,

my problem string in code inside jquery/javascript functions (that did not post here, because didn't think of faulty)

faulty string:

var deleteanswer = prompt("are sure want delete project?\nname: "+<?=$project['projname']?>+"\ncompany: "+<?=$project['compname']?>); 

correct string:

var deleteanswer = prompt("are sure want delete project?\nname: <?=$project['projname']?>\ncompany: <?=$project['compname']?>"); 

i switch use document.ready, instead of window.load

and use firefox, start check errors in f12 console -> errors

jshint nice tip, can check code there.

thanks lot feedback guys! =)


i've been using javascript , jquery on page now, , it's been working until now.

for reason none of code inside <script> tag fire anymore. maybe i'm missing important.

i've removed of code hope enough information. i've checked source code see if it's pointing right js file, , is.

also, adding code right before <title> works:

<script type="text/javascript"> $(document).ready(function(){   $("div").css("border", "3px solid red");  }); </script> 

anyways, here's parts of code:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">  <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" />  <!--<script src="jquery-1.10.2.min.js"></script>--> <script src="jquery/jquery-1.9.1.js"></script> <script src="jquery/ui/jquery.ui.core.js"></script> <script src="jquery/ui/jquery.ui.datepicker.js"></script> <link rel="stylesheet" type="text/css" href="jquery/themes/base/jquery-ui.css">  <link rel="stylesheet" type="text/css" href="style.css">  <title>title goes here</title>  </head>  <body> <script>     <!-- ########## window.load ############### -->     $(window).load(function(){         $('#topbarwrapper').hover(function() {             $('#topbardropdown').stop();             $('#topbardropdown').animate({top:'-30px'});         }, function() {             $('#topbardropdown').stop();             $('#topbardropdown').animate({top:'-60px'});         });          $('#deleteprojectbtn').click(deleteproject);         $('#cancelprojectbtn').click(cancelproject);          $( "#datepicker" ).datepicker({ dateformat: "yy-mm-dd" });     });      function somefunction(){         //do     }      function cancelproject(){         window.location = 'admin.php';     };      <!-- ########## document.ready ############### -->     $(document).ready(function(e) {         alert("document ready");         var mycompselector = document.getelementbyid('fcompanyselection');         mycompselector.selectedindex = parseint(<?=$project['companyid']?>)-1;          var mycatselector = document.getelementbyid('category');         mycatselector.selectedindex = parseint(<?=$project['categoryid']?>)-1;     });  </script> 

try :

<script>      function somefunction(){         //do     }      function cancelproject(){         window.location = 'admin.php';     };      /** ########## document.ready ############### **/     $(document).ready(function(e) {         alert("document ready");         $('#topbarwrapper').hover(function() {             $('#topbardropdown').stop();             $('#topbardropdown').animate({top:'-30px'});         }, function() {             $('#topbardropdown').stop();             $('#topbardropdown').animate({top:'-60px'});         });          $('#deleteprojectbtn').click(deleteproject);         $('#cancelprojectbtn').click(cancelproject);          $( "#datepicker" ).datepicker({ dateformat: "yy-mm-dd" });           var mycompselector = document.getelementbyid('fcompanyselection');         mycompselector.selectedindex = parseint(<?=$project['companyid']?>)-1;          var mycatselector = document.getelementbyid('category');         mycatselector.selectedindex = parseint(<?=$project['categoryid']?>)-1;     });  </script> 
  • use // inline comment, /* ... */ comment blocks /** ... **/ documentation purpose comment blocks
  • .load() ajax method load remote content element use $(document).ready(function(){}) or $(function(){})
  • dunno if it's intentionnal have php parts won't execute client side :

        var mycompselector = document.getelementbyid('fcompanyselection');     mycompselector.selectedindex = parseint(<?=$project['companyid']?>)-1;      var mycatselector = document.getelementbyid('category');     mycatselector.selectedindex = parseint(<?=$project['categoryid']?>)-1; 
  • remember try debugger console (f12 button on chrome) first make stripped jsfiddle minimalist code reproduce error. if of time code debugged while narrowing down bug.

  • prefer console.log('text here or javascript objects') rather alert()

here exemple code (i've commented out php part can run) : http://jsfiddle.net/techunter/mrzsh/


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -