Can't get 3 separate scripts to work together

Hi, I have three separate Javascripts in the header template for my site pages. One auto-fills a form field based on the value picked in a preceding field, the second is a date picker and the third is for sorting column values in a table output.

All work fine in isolation but I can’t get the three of them to work if they co-exist in the header. Any idea why/ I’m guessing there’s some form of conflict. At the moment the code is as below, and the date picker is the one that isn’t working for some reason. If I take the table sorter script away the date picker starts working. ???

  <!--Auto selector for Clients / Suppliers list e.g on Add New Transaction -->
  <script type="text/javascript">
	$(function(){
	$("select[name='_Category']").change(function(){
	var selected = $(this).val();
	$("select[name='_Name']").empty().load("getrowforselect.php?category="+selected);
          });
      }); 
</script> 
<!--Date picker-->
  <script type="text/javascript" >
  $(function() {
    $( "#datepicker1" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker2" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker3" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker4" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker5" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker6" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker7" ).datepicker({ dateFormat: "yy-mm-dd" });
	$( "#datepicker8" ).datepicker({ dateFormat: "yy-mm-dd" });
  });
  </script>
  <!--Script for sorting table columns-->
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<script type="text/javascript" src="scripts/jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function() 
    { 
		$("#invoices").tablesorter(); 
		$("#quotations").tablesorter(); 
		$("#clients").tablesorter(); 
		$("#prospects").tablesorter();
		$("#transactions").tablesorter();
		$("#projects").tablesorter();
		$("#jobs").tablesorter();
		$("#contracts").tablesorter();
    } 
); 
</script>

I’m not sure if this will help, but have you tried putting the line that loads jQuery first?

Thanks, just tried that and doesn’t work unfortunately…

Date picker seems to work fine if the table sorter script is removed. Definitely looks like a conflict but I don’t see why as they should be independent… :frowning:

Think I’ve just sorted it- removed the jquery call and used a different version. Seems ok. thanks!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.