当前位置:网站首页>Oninput one function to control multiple oninputs (take the contents of this input box as parameters) [very practical, very practical]
Oninput one function to control multiple oninputs (take the contents of this input box as parameters) [very practical, very practical]
2022-04-23 17:11:00 【ZHZHK001】
effect
oninput Take the contents of this input box as a parameter , Take the input box of the operation object as the parameter
One function can control multiple functions oninput The effect of
Knowledge point
1. Function encapsulation , The ginseng
2.this Usage of
3.getAttribute Usage of
The effect is as shown in the picture
The key codes are as follows
<tr>
<td>ID1</td>
<td>
<input id="P_PID" oninput="gainPName(this,'NAME1')" />
</td>
<td> name 1</td>
<td>
<input id="NAME1" />
</td>
</tr>
<tr>
<td>ID2</td>
<td>
<input id="P_FID" oninput="gainPName(this,'NAME2')" />
</td>
<td> name 2</td>
<td>
<input id="NAME2" />
</td>
<td>ID3</td>
<td>
<input id="P_MID" oninput="gainPName(this,'NAME3')" />
</td>
<td> name 3</td>
<td>
<input id="NAME3" />
</td>
</tr>
/** * Get... In real time ID Personnel information , And change the value of the corresponding input box * @param input This input box * @param toNameID Of another input box ID */
function gainPName(input,toNameID){
// console.log(input); // Get the contents of this input box
// console.log(input.getAttribute("ID")); // Get the of this input box ID
// console.log( $("#"+input.getAttribute("ID") ).val() ); // Get the input content of this input box
$("#"+toNameID).val(" unregistered "); // Assign initial value to
var result = gainPersonById( $("#"+input.getAttribute("ID") ).val() );
if(result.length==0){
$("#"+toNameID).val(" unregistered ");
}else{
if(result.get("flag")){
$("#"+toNameID).val(result.get("rs").NAME);
}else{
$("#"+toNameID).val(" unregistered ");
}
}
}
版权声明
本文为[ZHZHK001]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230553251729.html
边栏推荐
猜你喜欢
Webapi + form form upload file
Feign report 400 processing
Deep understanding of control inversion and dependency injection
Go language, array, string, slice
[WPF binding 3] listview basic binding and data template binding
Solution architect's small bag - 5 types of architecture diagrams
Detailed explanation of Milvus 2.0 quality assurance system
文件操作《二》(5000字总结篇)
[PROJECT] small hat takeout (8)
How vscode compares the similarities and differences between two files
随机推荐
About stream flow, write it down briefly------
VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
websocket
Calculation formula related to tolerance analysis
[registration] tf54: engineer growth map and excellent R & D organization building
freeCodeCamp----shape_ Calculator exercise
Copy constructor shallow copy and deep copy
文件操作《二》(5000字总结篇)
【生活中的逻辑谬误】稻草人谬误和无力反驳不算证明
Expression "func" tSource, object "to expression" func "tSource, object" []
Understanding of RPC core concepts
EF core in ASP Generate core priority database based on net entity model
线性代数感悟之2
Detailed explanation of C webpai route
. net type transfer
Redis docker installation
Basic case of Baidu map
Paging the list collection
Simulation of infrared wireless communication based on 51 single chip microcomputer
1-3 nodejs installation list configuration and project environment