如何在动态更改时检测输入值的更改.因为txt2上的更改清除了txt1中的值.我需要检测它已清除或更改.
Onchange不会这样做.
<input id="txt1" type="text" onchange="SetDefault();" onpaste="this.onchange();" oninput="this.onchange();">
<br>
<input id="txt2" type="text" onchange="SetDefaultSecond();" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<script>
function SetDefault(){
alert("Change1");
}
function SetDefaultSecond(){
$("#txt1").val('');
alert("Change2");
}
</script>
Run Code Online (Sandbox Code Playgroud) 在更改下拉列表时,应调用php函数.
在PHP函数内部,我将进行一些计算.稍后我需要设置一个文本框的值,否则PHP函数应该返回一个值,该值应该在javascript中捕获并将该值设置为文本框控件.
我的html功能是
<select name="sltLeaveType" id="sltLeaveType" class="formSelect" onchange="TotalCountsOfPL(this.value)">
<?php
<option></option>
<option></option>
</select>
Run Code Online (Sandbox Code Playgroud)
并且在PHP函数中放置了D:/Project/EmployeeDetails/EmpLeave.php
class clsGetTotalPL
{
function GetTotalPL($EmployeeId)
{
$query = "select count(leave_request_id) from hs_hr_leave_requests where leave_type_id='LTY002' AND employee_id=".$EmployeeId.";";
return $query;
}
Run Code Online (Sandbox Code Playgroud)
所以现在请[给我提供一个JQuery函数来调用这个Php函数来调用下拉列表中每个更改的GetTotalPL()函数.