Just help. Newb question :)

M

Matthew Del Buono

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
 
E

Evertjan.

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top