469,356 Members | 2,016 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

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
Jul 23 '05 #1
1 950
Matthew Del Buono wrote on 29 jun 2004 in comp.lang.javascript:
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?


<script type="text/javascript">
function surround() {
t = document.getElementById("myArea")
t.value = '"' + t.value + '"'
}
</script>
<textarea id="myArea">bla blah</textarea>
<br>
<button onclick="surround()">surround</buttom>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by claudel | last post: by
reply views Thread by David E. | last post: by
3 posts views Thread by claudel | last post: by
6 posts views Thread by Sean Berry | last post: by
11 posts views Thread by The_Kingpin | last post: by
2 posts views Thread by Benign Vanilla | last post: by
1 post views Thread by HateSpam | last post: by
1 post views Thread by gerg | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.