Obtain the selected text in the text box and insert the text dynamically.

Source: Internet
Author: User
<Script language = "JavaScript" src = "JS/settags. js"> </SCRIPT> function apptag (tagcode)
{
Document. postmessage. Message. Value + = tagcode;
} Function inserttag (tagbegin, tagend)
{
If (document. Selection) & (document. selection. type = "text ")){
VaR range = Document. selection. createRange ();
VaR ch_text = range. text;
Range. Text = tagbegin + ch_text + tagend;
}
Else
{
Document. postmessage. Message. value = tagbegin + document. postmessage. Message. Value + tagend;
Document. postmessage. Message. Focus ();
}
} </SCRIPT> Call: Icon button for performing the operation: <A href = "javascript: apptag ('[imgface1]')"> </a> <a href =" javascript: inserttag ('[B]', '[/B]') "> </a>
[Imgface1], [B], [/B] Are the text to be inserted var range = Document. selection. createRange ();
VaR ch_text = range. text;
This is the text box for operations on the selected text box: <asp: textbox id = "message" runat = "server" maxlength = "100" textmode = "multiline" rows = "15" width = "100%"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.