Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Cursor location

  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    128
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Cursor location

    Hi everybody,

    The code written below is made with one of my previous codes. That was working on the selected texts. I just need it to be edited to Cursor location point. Basicly when someone clicks a button I want this prompt window appear and ask the client the name of the image. When they type and click ok then the code must write [img=valuenteredtoprompt] whereever the cursor is located in my text area. Here is the code to be edited. My text area code and how I call the script.

    function addimage(id) {
    var textEl = document.getElementById(id);
    var selectedText = (document.all) ? document.selection.createRange().text : (textEl.value).substring(textEl.selectionStart, textEl.selectionEnd);
    var name=prompt("Please enter image name","")
    if (name!=null && name!="")
    {
    textEl.value = textEl.value.replace(selectedText, selectedText + "[img=" + name + "]");
    }

    }


    <textarea name="aboutus" rows="6" cols="50"><%=ors.Fields("aboutus").value%></textarea>

    <input type="button" value="Add Image" onClick="addimage('aboutus');" />

    I will be glad if you can help...

    Thanks

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One problem I see is

    <textarea name="aboutus" ...

    needs to be

    <textarea name="aboutus" id="aboutus" ...

    otherwise your document.getElementById() will be null.

    david_kw

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

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