Insert a string into the input domain (where the cursor is located). This article will show you how to implement Javascript. If you are interested, refer
The Code is as follows:
/**
* Insert a string to the input field (cursor position)
* @ Param $ t document. getElementById ('fieldid ')
* @ Param myValue the value to be inserted
**
Function addSplitToField ($ t, myValue ){
If (document. selection ){
$ T. focus ();
Sel = document. selection. createRange ();
Sel. text = myValue;
$ T. focus ();
} Else if ($ t. selectionStart | $ t. selectionStart = '0 '){
Var startPos = $ t. selectionStart;
Var endPos = $ t. selectionEnd;
Var scrollTop = $ t. scrollTop;
$ T. value = $ t. value. substring (0, startPos) + myValue + $ t. value. substring (endPos, $ t. value. length );
This. focus ();
$ T. selectionStart = startPos + myValue. length;
$ T. selectionEnd = startPos + myValue. length;
$ T. scrollTop = scrollTop;
} Else {
$ T. value + = myValue;
$ T. focus ();
}
}