Copy code code as follows:
<pre name= "code" class= "JavaScript" >/**
* Insert a string into the input field (cursor location)
* @param $t document.getElementById (' FieldID ')
* @param myvalue the value to insert
* *
Function Addsplittofield ($t, Myva Lue) {
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 ();
}
}
</pre><br><br>