Just help. Newb question :)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Del Buono

    Just help. Newb question :)

    Sorry, I don't know that much about javascript. Some, not a lot. I was
    hoping someone could point me in the right direction for this:

    I have a textarea with an ID. I would like that textarea to be modified by a
    bit of javascript coding. The user would click on the button (which
    obviously would have an onClick property) that would cause any selected text
    to become surrounded by something. Let's say quotes for this example. How
    could I get javascript to surround the selected text by quotes?

    Thanks for any help!
    -- Matt


  • Evertjan.

    #2
    Re: Just help. Newb question :)

    Matthew Del Buono wrote on 29 jun 2004 in comp.lang.javas cript:
    [color=blue]
    > I have a textarea with an ID. I would like that textarea to be
    > modified by a bit of javascript coding. The user would click on the
    > button (which obviously would have an onClick property) that would
    > cause any selected text to become surrounded by something. Let's say
    > quotes for this example. How could I get javascript to surround the
    > selected text by quotes?[/color]

    <script type="text/javascript">
    function surround() {
    t = document.getEle mentById("myAre a")
    t.value = '"' + t.value + '"'
    }
    </script>


    <textarea id="myArea">bl a blah</textarea>
    <br>
    <button onclick="surrou nd()">surround</buttom>



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    Working...