Get KoolPHP UI with 30% OFF!

Using multiple datepickers on the same form.

Terry
What I am trying to do is use datepicker for multple date required in a single form. Here is my code:
$datepicker = new KoolDatePicker("datetimepicker"); //Create calendar object
$datepicker->scriptFolder = "KoolPHPSuite/KoolControls/KoolCalendar/";//Set scriptFolder
$datepicker->styleFolder="default";
$datepicker->DateFormat = "M jS, Y";
$datepicker->Value = $this->convert_date($cutoff); // converts the database stored format yyyymmdd to a human date format of Aug 27, 2015
$eodpicker = new KoolDatePicker("datetimepicker");
$eodpicker->scriptFolder = 'KoolPHPSuite/KoolControls/KoolCalendar/';
$eodpicker->styleFolder = 'default';
$eodpicker->DateFormat = "M jS, Y";
$eodpicker->Value = $this->convert_date($erDate);
//Change date and time format
$datepicker->Init();
$eodpicker->Init();
.......
<tr>
<td width = '50px'>&nbsp;</td>
<td align = 'right' valign = 'center'><b>Commodity:&nbsp;</b></td>
<td align = 'left' valign = 'center'><input type = 'text' name = 'commodity' value = '<?php echo $commodity; ?>' /></td>
<td align = 'right' valign = 'center'><b>Early Return Date: </b></td>
<td align = 'left' valign = 'center'><?php echo $eodpicker->Render(); ?></td>
<td align = 'right' valign = 'center'><b>Cutoff:&nbsp;</b></td>
<td align = 'left' valign = 'center'><?php echo $datepicker->Render();?></td>
</tr>
The form displays properly however when I select the eodpicker I see date for both of the datepickers highlighted, and then the original datepicker I am unable to access.... If anyone has any insite into this it would be greatly appreciated.
Posted Sep 16, 2015 Kool
Anthony Amolochitis
The problem with your date pickers is that they are named the same.
Try giving each datepicker a different name. That should fix the issue
Posted Nov 28, 2015 Kool -
ADavid Wulkan
I was having the same problem until I found this: http://doc.koolphp.net/Controls/KoolCalendar/index.php
I thought the parameter was a type it's not, it's the calendar name.
This worked for me.
<?php include "inc/header_inc.php"; ?>
<!-- test.php -->
<!-- 2016011 This code returns start and end date calendars-->
<!--  -->
        <?php
//External
	require_once $KoolControlsFolder."/KoolCalendar/koolcalendar.php";	
	
	$datepicker1 = new KoolDatePicker("datepicker1"); //Create calendar object
	$datepicker1->scriptFolder = $KoolControlsFolder."/KoolCalendar";//Set scriptFolder
	$datepicker1->styleFolder="default";
	
	$datepicker2 = new KoolDatePicker("datepicker2"); //Create calendar object
	$datepicker2->scriptFolder = $KoolControlsFolder."/KoolCalendar";//Set scriptFolder
	$datepicker2->styleFolder="default";
	
	//Change date and time format
	$datepicker1->DateFormat = "M jS, Y";
	$datepicker2->DateFormat = "M jS, Y";
	
	$datepicker1->Init();
	$datepicker2->Init();
?>
        <form id="form1" method="post">	
        <table><tr>
           <td width="150px" style="vertical-align:top">
            <div style="padding-top:10px;padding-bottom:10px;width:100px;">
              Start date:
              <br/>
              <?php echo $datepicker1->Render();?>
              <?php
                if($datepicker1->Value!=null) {
                   echo "<b>Start date:</b> ".$datepicker1->Value;
                }
               ?>
		
            </div>
          </td>
          <td width="50px"></td>
          <td width="150px" style="vertial-align:top">
            <div style="padding-top:10px;padding-bottom:10px;width:100px;">
              End date:
              <br/>
              <?php echo $datepicker2->Render();?>
                <?php
                  if($datepicker2->Value!=null) {
                     echo "<b>End date:</b> ".$datepicker2->Value;
                  }
                 ?>		
            </div>
          </td>
          <td width="15px"></td>
          <td width="150px" style="vertical-align:bottom">
              <div style="padding-top:10px;padding-bottom:10px;width:100px;">
                <input type="submit" value="Submit" />
              </div>
          </td>
</body></html>
Posted Jan 17, 2016 , edited Jan 17, 2016 Kool