当前位置:网站首页>Textbox in easyUI inserts content at the cursor position
Textbox in easyUI inserts content at the cursor position
2022-07-27 03:35:00 【The newborn sun】
<input id="fileName" name="filename" class="easyui-textbox lg_width" data-options="tipPosition:'bottom'" type="text" >
title = "${aaa}";// What to insert
insertLabelText("fileName",title);// Calling method ,fileName by id="fileName" Of input label
function insertLabelText(destobj,labelText) {
let lastIndex = getCursortPosition(destobj);// Get cursor position
let oldText = $('#'+destobj).textbox('getValue');// Get the value of the input box
let newText = buildNewText(oldText, labelText, lastIndex);// Splice the value of the input box with the value to be inserted
$('#'+destobj).textbox('setValue',newText);// Set the spliced value to the input box
}
// Get cursor position
function getCursortPosition(destobj) {
var cursorIndex = "-1";
var obj = $('#'+destobj).next()[0].children[0]; //easyui Generated controls , All the information entered is on this
if (document.selection) {
//IE browser
obj.focus ();
var range= document.selection.createRange();
range.moveStart ('character', -obj.value.length);
cursorIndex= range.text.length;
}else if (obj.selectionStart || obj.selectionStart==0) {
// Not IE browser
cursorIndex= obj.selectionStart;
}
return cursorIndex;
}
// Concatenate new strings
function buildNewText(oldText,labelText,lastIndex){
let newText = oldText.substring(0, lastIndex) + labelText;// Insert at the beginning and end
if(oldText.length!=lastIndex&&oldText.length!=0){
// Insert in the middle of a character
newText += oldText.substring(lastIndex, oldText.length);
}
return newText;
}
边栏推荐
- Double disk: the main differences between DFS and BFS, the differences in ideology, and the differences in code implementation
- Database usage security policy
- How to conduct 360 assessment
- opiodr aborting process unknown ospid (21745) as a result of ORA-609
- 【1206. 设计跳表】
- 【正则】判断, 手机号,身份证号
- Fastboot刷机
- Spark Learning Notes (V) -- spark core core programming RDD conversion operator
- Mysql database related operations
- Unity game, the simplest solution of privacy agreement! Just 3 lines of code! (Reprinted)
猜你喜欢

Network security / penetration testing tool awvs14.9 download / tutorial / installation tutorial

复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些

mysql如何优化

Spark: ranking statistics of regional advertising hits (small case)

It's too strong. An annotation handles the data desensitization returned by the interface

redis秒杀案例,跟着b站尚硅谷老师学习

Spark Learning Notes (IV) -- spark core programming RDD

MySQL underlying data structure

快速排序及优化

Duplicate disc: what are the basic attributes of an image? What do you know about images? What are the parameters of the image
随机推荐
Does Oracle have a distributed database?
It's too strong. An annotation handles the data desensitization returned by the interface
LPCI-252通用型PCI接口CAN卡的功能和应用介绍
Banyan loan,
客户端发送一条sql如何与服务器交互
How to uniquely identify a user SQL in Youxuan database cluster
mysql如何优化
【正则】判断, 手机号,身份证号
Redis source code learning (33), command execution process
PyCharm中Debug模式进行调试详解
What are "full five unique" and "full two unique"? Any difference?
榕树贷款C语言结构体里的成员数组和指针
带你了解什么是 Web3.0
Mysql: summary of common sub database and sub table schemes of Internet companies
深入理解Mysql索引底层数据结构与算法
【常用搜索问题】111
若依的环境的部署以及系统的运行
网络安全/渗透测试工具AWVS14.9下载/使用教程/安装教程
C语言const用法详解
Submodule cache cache failure