How: split text box text at cursor

G

Guest

This has got to be simpler than I am making it.
I have a text box where the user enters a search string. I have some
buttons that will insert some logic tokens into the search string (i.e. UTAH
<AND> WATER)
Currently, clicking the <AND> button, just addes the string "<AND>" to the
end of the text in the text box. However, I want the user to be able to
click anywhere in the search string they entered (i.e. UTAH WATER, click
between UTAH and WATER) then click the <AND> button and have <AND> inserted
at the point where they clicked. So far I have only been able to replace
the entire text with the logic token. I have tried TextRange, no luck.
Currently I put "<AND>" into the clipboard and then use execScript to try and
paste the text at the insertion point, but I cannot seem to get the SendKeys
to work.

Any suggestions on how I should be trying to insert text at the click point?

Unsucessful Atttemps (working off the text box click for testing purposes):

function TextSearchClick(evt) {
var mx = document.frmMain.cmdAND.createTextRange();
var x = mx.execCommand("Copy");
moTR = document.frmMain.txtSearch.createTextRange();
msBK = moTR.getBookmark();
var bSet = moTR.execCommand("Overwrite","false");
var bRet = moTR.execCommand("Paste");
(OVERWRITES ENTIRE TEXT STRING)


And anouther failure,
var sKeys = "^(v)";
var bR = window.execScript ("SendKeys " & sKeys,"vbscript")

Any and all suggestions appreciated!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top