SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using JS to insert code into a textbox

    I have the following code in a page of mine to add certain code when a link is clicked into a text box

    PHP Code:
    function addcode(code) {
        if (
    code == "row_def") {
            
    code "<tr bgcolor=\"$bgcolor3\"><td nowrap>\n\r\n\r</td></tr>";
        }
        if (
    code == "nb") {
            
    code "&nbsp;"
        
    }
        if (
    parent.top.document.block.contents.createTextRange && parent.top.document.block.contents.caretPos) {          
            var 
    caretPos parent.top.document.block.contents.caretPos;      
            
    caretPos.text code+"";
            
    parent.top.document.block.contents.focus();
        }    else {
            
    parent.top.document.block.contents.value += code+"";
          
    parent.top.document.block.contents.focus();
        }    

    what I also want to do is set the cursor between the carriage returns in the row_def code, how can I do that?
    Last edited by thetakerfan; Jul 14, 2001 at 09:01.

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm 99% sure there is no way to set the cursor position inside a textbox or textarea.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •