Page 1 of 1

[SOLVED] calling a javascript (image, onclick, global content)

Posted: Mon Feb 16, 2009 6:23 pm
by jdwork
Hello,

  I have a javascript calendar and it works perfectly.  When the page opens a lovely multi-select calendar is availble.

{global_content name='calculon'}

Code: Select all

  <link rel="stylesheet" type="text/css" href="uploads/epoch_styles.css" />
  {literal}
  <__script__ type="text/javascript" src="uploads/epoch_classes.js"></__script>
  <__script__ type="text/javascript">
	var bas_cal,dp_cal,ms_cal;      
  window.onload = function () {
	ms_cal  = new Epoch('epoch_multi','flat',document.getElementById('multi_container'),true);
  };
  </__script> 
  {/literal}
  <div id="multi_container"></div>
  For testing, I have a hard coded an array which will highlight the chosen dates through the calendar's addDates() function.

{global_content name='add2'}

Code: Select all

  {literal}
  <__script__ type="text/javascript" language="javascript"><!--
  var date1 = new Date(2009,1,15) //feb 15, 2006 
  var date2 = new Date(2006,1,17) //feb 17, 2006
  var myArray = new Array(date1,date2);
  ms_cal.addDates(myArray); //add the dates and display them on the calendar!
  </__script>
  {/literal}
I am unsuccesfully trying to execute the global content block from a button image link onclick.

Please let me know if this is possible and how, or if there is a better way.

cheers

Re: calling a javascript (image, onclick, global content)

Posted: Mon Feb 16, 2009 7:47 pm
by jdwork
SOLVED

Instead of calling the Global Content Block (containing array, variables & function) onClick, I added it to the page.

Code: Select all

{call global with array variables & function}
<img onclick="ms_cal.addDates(myArray)" src="uploads/images/calculator_icon.gif" alt="" width="57" height="57"
I can now access the arrays as needed. ;D

I may have some trouble inserting sql data in there, but I will cross that bridge when I get there. :-\

Anyways, hope this helps someone looking for a quick way to execute a java function in a global content block.

cheers