PDA

View Full Version : click-content goes in textarea



insanemonkey
09-23-2007, 04:20 AM
Hello im a newbie to javascript,
but I cant find this anywhere, I am looking for a code so when you click a button the button will place something in my textarea box.

I am using this for BBcode

so an example.
I click a picture and it places the bbcode into my html textarea box, can anyone help me! I think this is javascript?

djr33
09-23-2007, 05:15 AM
onClick="whatever.value += 'something';" or something similar to that.

That's the basic idea behind it.

You could just look at the script on a working page to get some idea how it works.

insanemonkey
09-23-2007, 11:57 AM
thankyou, ill try to look for a script that has that....

so I have to give the textarea a value to so the onclick is sending it to the value.

i think thats right, Thankyou!



Is there a away anyone can post a script example, I have no clue!

insanemonkey
09-23-2007, 12:31 PM
I found this but I was wondering if it is possible to make more input buttons do a onclick with different functions?



<html>
<head>
<script>
function addtxt(input) {
var obj=document.getElementById(input)
obj.value+="blah test 123"
}
</script>
</head>
<body>
<textarea id="textarea1"></textarea>
<br><input type="button" value="Write blah blah" onclick="addtxt('textarea1')">
</body>
</html>