当前位置:网站首页>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
边栏推荐
- Shell-cut命令的使用
- [markdown notes]
- 1-3 nodejs installation list configuration and project environment
- 【WPF绑定3】 ListView基础绑定和数据模板绑定
- Preliminary understanding of promse
- ASP. Net core configuration options (Part 2)
- 线性代数感悟之1
- Solution architect's small bag - 5 types of architecture diagrams
- SQL database
- Zhimeng dedecms security setup Guide
猜你喜欢
随机推荐
Multithreaded @ async thread pool
Freecodecamp ---- budget & category exercise
El cascade and El select click elsewhere to make the drop-down box disappear
Further optimize Baidu map data visualization
Tencent resolves the address according to the IP address
线性代数感悟之2
Signalr can actively send data from the server to the client
. net cross platform principle (Part I)
VLAN advanced technology, VLAN aggregation, super VLAN, sub VLAN
RTKLIB 2.4.3源码笔记
Grpc gateway based on Ocelot
ASP. Net core configuration options (Part 1)
Use of shell cut command
基于51单片机红外无线通讯仿真
手写事件发布订阅框架
Use of shell sed command
Using quartz under. Net core -- preliminary understanding of [2] operations and triggers
Wiper component encapsulation
Scope and scope chain in JS
线性代数感悟之1