Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input text where selected

Status
Not open for further replies.

Extreme43

Programmer
Dec 21, 2004
23
AU
Hello all :)
happy new years

Im not good at javascript but have got this code to input text into the textbox with tags

but what i want to do is to replace only the selected text instead of the whole thing
i have mucked around with it but cant seem to get anything
Code:
<SCRIPT LANGUAGE="JavaScript">

function seeTextArea (form,tag) {
if (document.form1.text.value != '')
{
document.form1.text.value = '<' + tag + '>' + form.text.value + '</' + tag + '>'
alert (form.text.value);
}
}

</SCRIPT>

can anyone help ?
 
Search for getSelectionStart() and getSelectionEnd(), I believe.

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top