Page 1 of 1

Need Help in getting values in OnClick function

Posted: Fri Mar 05, 2010 3:05 pm
by jibzonline
I am new to php. I was able to develop the code below for a date picker with some help from the internet. What I need now is a button with an onclick event that will get the selected dates and store it to 2 variables

the selected date can be obtained with the $myCalendar1->getDate(); function and $myCalendar2->getDate(); for the second calendar. I am able to save the dates when the form loads. The code includes for a popup for javasript. I need to save the selected dates to two variables somehow in onclick function


If I could put

$stdt = $myCalendar1->getDate();
echo $stdt ;
$eddt = $myCalendar2->getDate();
echo $eddt ;


in a function and call it while onclick event atleast

Code: Select all

<?php
require_once('classes/tc_calendar.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 
<title>TriConsole - Programming, Web Hosting, and Entertainment Directory</title>
 
 
<link href="calendar.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="calendar.js"></script>
 
<style type="text/css">
body { font-size: 11px; font-family: "verdana"; }
 
pre { font-family: "verdana"; font-size: 10px; background-color: #FFFFCC; padding: 5px 5px 5px 5px; }
pre .comment { color: #008000; }
pre .builtin { color:#FF0000;  }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td>
              <form name="form1" method="post" action="">
                <p><b>Date Pair Example</b></p>
                <div style="float: left;">
                  <div style="float: left; padding-right: 3px; line-height: 18px;">from:</div>
                  <div style="float: left;">
                    <?php
      $myCalendar1 = new tc_calendar("date3", true, false);
      $myCalendar1->setIcon("./images/iconCalendar.gif");
      $myCalendar1->setDate(1, 1, 2010);
      $myCalendar1->setPath("./");
      $myCalendar1->setYearInterval(1970, 2020);
      //$myCalendar->dateAllow('2009-02-20', "", false);
      $myCalendar1->writeScript();  
      ?>
                  </div>
                </div>
                <div style="float: left;">
                  <div style="float: left; padding-left: 3px; padding-right: 3px; line-height: 18px;">to</div>
                  <div style="float: left;">
                    <?php
      $myCalendar2 = new tc_calendar("date4", true, false);
      $myCalendar2->setIcon("./images/iconCalendar.gif");
      $myCalendar2->setDate(1, 4, 2010);
      $myCalendar2->setPath("./");
      $myCalendar2->setYearInterval(1970, 2020);
      //$myCalendar->dateAllow("", '2009-11-03', false);
      $myCalendar2->writeScript();    
      
      ?>
      
                 </div>
                </div>
                <p>
                  <input type="button" name="button2" id="button2" value="Check the value" onClick="javascript&#058;alert('Date select from '+this.form.date3.value+' to '+this.form.date4.value);">
                </p>
                <?php
                
                 $stdt = $myCalendar1->getDate(); 
                 echo     $stdt ;  
                 $eddt = $myCalendar2->getDate(); 
                 echo     $eddt ;  
    
                 ?>
                
                
                
                
                
              </form>
            </td>
        </tr>
      </table>
      </td>
  </tr>
</table>
</body>
</html>
 

Re: Need Help in getting values in OnClick function

Posted: Fri Mar 05, 2010 11:18 pm
by jibzonline
ok let me make simple,

i just need to save the values of

$myCalendar1->getDate();
$myCalendar2->getDate();


when i click the button after i have selected dates on my calendar

Jibz