Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>try this:)</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function TotalCountsOfPL(str) { if(iset(session_unregister("mySessionVariable"))) { session_destroy(); }; session_start(); session_register("mySessionVariable"); if(str!="") { $_SESSION["mySessionVariable"] = str; document.getElementById("AjxSelectedLeaveType").innerHTML=str; } if (str=="") { document.getElementById("AjxTakenLeave").innerHTML=""; //document.getElementById("AjxLeaveType").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("AjxTakenLeave").innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","getPLCount.php",true); xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $prevEmployeeId= (isset($_POST['cmbEmployeeId'])) ? $_POST['cmbEmployeeId'] : ""; $prevLeaveFromDate = (isset($_POST['txtLeaveFromDate'])) ? $_POST['txtLeaveFromDate'] : ""; $prevLeaveToDate = (isset($_POST['txtLeaveToDate'])) ? $_POST['txtLeaveToDate'] : ""; $prevLeaveType = (isset($_POST['sltLeaveType'])) ? $_POST['sltLeaveType'] : ""; $prevToTime = (isset($_POST['sltLeaveToTime'])) ? $_POST['sltLeaveToTime'] : "";+ // Gnanendra .. Here I have consider the variable $prevFromTime as "Total days" selected by the dropdownlist $prevFromTime = (isset($_POST['sltLeaveFromTime'])) ? $_POST['sltLeaveFromTime'] : ""; //G Comment below $prevTotalTime = (isset($_POST['txtLeaveTotalTime'])) ? $_POST['txtLeaveTotalTime'] : ""; $prevComments = (isset($_POST['txtComments'])) ? $_POST['txtComments'] : ""; $timeElementClass = (!empty($prevLeaveFromDate) &amp;&amp; ($prevLeaveFromDate == $prevLeaveToDate)) ? "show" : "hide"; $AjxSelectedLeaveType=(isset($_POST['AjxSelectedLeaveType'])) ? $_POST['AjxSelectedLeaveType'] : ""; $AjxTakenLeave=(isset($_POST['AjxTakenLeave'])) ? $_POST['AjxTakenLeave'] : ""; ?&gt; &lt;form id="frmLeaveApp" name="frmLeaveApp" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;?leavecode=Leave&amp;amp;action=&lt;?php echo $modifier; ?&gt;"&gt; &lt;input type="hidden" value="&lt;?php echo $token;?&gt;" name="token" /&gt; &lt;?php if (isset($confirmDate)) { ?&gt; &lt;input type="hidden" name="confirmDate" value="&lt;?php echo $prevLeaveFromDate; ?&gt;"/&gt; &lt;?php } ?&gt; &lt;?php if (isset($role)) { ?&gt; &lt;?php if(($role == authorize::AUTHORIZE_ROLE_ADMIN) || ($role == authorize::AUTHORIZE_ROLE_SUPERVISOR)){ ?&gt; &lt;label for="cmbEmployeeId"&gt;&lt;?php echo $lang_Leave_Common_EmployeeName; ?&gt;&lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt; &lt;div&gt; &lt;input type="hidden" name="cmbEmployeeId" id="cmbEmployeeId" value="&lt;?php echo isset($prevEmployeeId) ? $prevEmployeeId : ""; ?&gt;" /&gt; &lt;div class="yui-ac" id="employeeSearchAC" style="float: left"&gt; &lt;input name="txtEmployeeId" autocomplete="off" class="yui-ac-input" id="txtEmployeeId" type="text" value="&lt;?php echo isset($empName) ? CommonFunctions::escapeHtml($empName) : ""; ?&gt;" tabindex="2" onfocus="showAutoSuggestTip(this)" style="color: #999999" /&gt; &lt;div class="yui-ac-container" id="employeeSearchACContainer" style="top: 28px; left: 10px;"&gt; &lt;div style="display: none; width: 159px; height: 0px; left: 100em" class="yui-ac-content"&gt; &lt;div style="display: none;" class="yui-ac-hd"&gt;&lt;/div&gt; &lt;div class="yui-ac-bd"&gt; &lt;ul&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;li style="display: none;"&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div style="display: none;" class="yui-ac-ft"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div style="width: 0pt; height: 0pt;" class="yui-ac-shadow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;br class="clear"/&gt; &lt;?php } ?&gt; &lt;?php } ?&gt; &lt;label for="sltLeaveType"&gt;&lt;?php echo $lang_Leave_Common_LeaveType; ?&gt;&lt;/label&gt; &lt;select name="sltLeaveType" id="sltLeaveType" class="formSelect" onchange="TotalCountsOfPL(this.value)"&gt; &lt;?php $skippedLeaveTypesCount = 0; if (is_array($records[1])) { foreach ($records[1] as $record) { $className = get_class($record); if ($className == 'LeaveQuota') { if ($record-&gt;isLeaveQuotaDeleted()) { $skippedLeaveTypesCount++; continue; } } $selected = ($record-&gt;getLeaveTypeID() == $prevLeaveType) ? 'selected="selected"' : ""; ?&gt; &lt;option &lt;?php echo $selected;?&gt; value="&lt;?php echo $record-&gt;getLeaveTypeID();?&gt;"&gt;&lt;?php echo $record-&gt;getLeaveTypeName(); ?&gt;&lt;/option&gt; &lt;?php } if ($skippedLeaveTypesCount == count($records[1])) { ?&gt; &lt;option value="-1"&gt;-- &lt;?php echo $lang_Error_NoLeaveTypes; ?&gt; --&lt;/option&gt; &lt;?php } } else { ?&gt; &lt;option value="-1"&gt;-- &lt;?php echo $lang_Error_NoLeaveTypes; ?&gt; --&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;br class="clear"/&gt; &lt;!--Gnanendra Here the Leave date range will get--&gt; &lt;?php if (!(is_array($records[1])) &amp;&amp; ($modifier == 'Leave_Apply')) { ?&gt; &lt;div class="notice"&gt;&lt;?php echo $lang_Leave_Common_LeaveQuotaNotAllocated; ?&gt;&lt;/div&gt; &lt;br class="clear"/&gt; &lt;?php } ?&gt; &lt;label for="txtLeaveFromDate"&gt;&lt;?php echo $lang_Leave_Common_FromDate; ?&gt;&lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt; &lt;input name="txtLeaveFromDate" type="text" id="txtLeaveFromDate" size="10" value="&lt;?php echo $prevLeaveFromDate; ?&gt;" class="formDateInput"/&gt; &lt;input type="button" name="Submit" value=" " class="calendarBtn" id="btFromDate"/&gt; &lt;br class="clear"/&gt; &lt;label for="txtLeaveToDate"&gt;&lt;?php echo $lang_Leave_Common_ToDate; ?&gt;&lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt; &lt;input name="txtLeaveToDate" type="text" id="txtLeaveToDate" size="10" value="&lt;?php echo $prevLeaveToDate; ?&gt;" class="formDateInput"/&gt; &lt;input type="button" name="Submit" value=" " class="calendarBtn" id="btToDate"/&gt; &lt;br class="clear"/&gt; &lt;div id="trTime1" class="&lt;?php echo $timeElementClass;?&gt;"&gt; &lt;label for="sltLeaveFromTime"&gt;&lt;?php echo $lang_Leave_Common_FromTime; ?&gt;&lt;/label&gt; &lt;?php $lang_Leave_Common_FromTime="Total Days"; ?&gt; &lt;label for="sltLeaveFromTime"&gt;&lt;?php echo $lang_Leave_Common_FromTime; ?&gt;&lt;/label&gt; &lt;select name="sltLeaveFromTime" id="sltLeaveFromTime" onchange="fillTimes();" class="formTimeSelect"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;!-- It will the time to the drop downlist (00:00 to 23:59) --&gt; &lt;?php for ($i=$startTime; $i&lt;=$endTime; $i+=$interval) { $timeVal = date('H:i', $i); $selected = ($timeVal == $prevFromTime) ? 'selected="selected"' : ""; ?&gt; &lt;option &lt;?php echo $selected; ?&gt; value="&lt;?php echo $timeVal; ?&gt;" &gt;&lt;?php echo LocaleUtil::getInstance()-&gt;formatTime($timeVal); ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;label for="sltLeaveToTime"&gt;&lt;?php echo $lang_Leave_Common_ToTime; ?&gt;&lt;/label&gt; &lt;select name="sltLeaveToTime" id="sltLeaveToTime" onchange="fillTimes();" class="formTimeSelect"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;?php for ($i=$startTime; $i&lt;=$endTime; $i+=$interval) { $timeVal = date('H:i', $i); $selected = ($timeVal == $prevToTime) ? 'selected="selected"' : ""; ?&gt; &lt;option &lt;?php echo $selected; ?&gt; value="&lt;?php echo $timeVal; ?&gt;" &gt;&lt;?php echo LocaleUtil::getInstance()-&gt;formatTime($timeVal); ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;br class="clear"/&gt; &lt;label for="txtLeaveTotalTime"&gt;&lt;?php echo $lang_Leave_Common_TotalHours; ?&gt;&lt;/label&gt; &lt;input name="txtLeaveTotalTime" id="txtLeaveTotalTime" size="4" onchange="fillTimes();" value="&lt;?php echo $prevTotalTime; ?&gt;" class="formInputText" style="width:3em;"/&gt; &lt;br class="clear"/&gt; &lt;/div&gt; &lt;div id="trTime2" class="&lt;?php echo $timeElementClass;?&gt;"&gt; &lt;/div&gt; &lt;div id="trTime3" class="&lt;?php echo $timeElementClass;?&gt;"&gt; &lt;/div&gt; &lt;div id="trTime4" class="&lt;?php echo $timeElementClass;?&gt;"&gt; &lt;/div&gt; &lt;br class="clear"/&gt; &lt;label for="txtComments"&gt;&lt;?php echo $lang_Leave_Common_Comment; ?&gt;&lt;/label&gt; &lt;textarea name="txtComments" id="txtComments" class="formTextArea" rows="3" cols="20" &gt;&lt;?php echo $prevComments;?&gt;&lt;/textarea&gt; &lt;!-- --&gt; &lt;input name="AjxSelectedLeaveType" type="text" id="AjxSelectedLeaveType" size="30" value="&lt;?php (isset($_POST['AjxSelectedLeaveType'])) ? $_POST['AjxSelectedLeaveType'] : "Leave Type";?&gt;" class="formDateInput"/&gt; &lt;input name="AjxTakenLeave" type="text" id="AjxTakenLeave" size="30" value="&lt;?php (isset($_POST['AjxTakenLeave'])) ? $_POST['AjxTakenLeave'] : "Taken Leave";?&gt;" class="formDateInput"/&gt; &lt;!-- --&gt; &lt;br class="clear"/&gt; &lt;div class="formbuttons"&gt; &lt;input type="button" class="&lt;?php echo $btnClass;?&gt;" id="saveBtn" onclick="addSave();" onmouseover="moverButton(this);" onmouseout="moutButton(this);" value="&lt;?php echo $btnTitle;?&gt;" title="&lt;?php echo $btnTitle;?&gt;"/&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; And the Following is getPLCount.php &lt;?php $q=$_POST["AjxSelectedLeaveType"]; $Eid=$_SESSION["mySessionVariable"]; $con = mysql_connect('localhost', 'gnuser', 'anu123'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("My_Database", $con); $EmployeeId= $q; if (isset($q)) { $query = "select count(leave_request_id) from leave_requests where leave_type_id='LTY002' AND employee_id=".$q.";"; } if(isset($Eid)) { $query = "select count(leave_request_id) from leave_requests where leave_type_id='LTY002' AND employee_id=".$Eid.";"; } $result = mysql_query($query); echo "document.getElementById('AjxTakenLeave').innerHTML={$result}"; mysql_close($con); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload