button that pastes text in a textfield

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Simply this is what I would like to accomplish. I want a text area, and when you click on a link, or button, it pastes text in the textarea, where the cursor is. Is this at all possible in javascript, dhtml, any other?

Like if the user pressed the button ten times, it would paste the text in that textarea 10x.

Thanx for your help.

VulKen

IRS Motto: We got what it takes, to take what you got.

Pimpin like a pimp with an electrofied pimpin machine!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Vulken,

Don't know what you mean by "where the cursor is", but the link should look like:

Add Text

Vinny

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I think I know what Vulken wants. I've seen something similar of a forum. They used it to insert HTML tags. (but I forgot where they are)

(textarea)
blah blah blah |blah blah
(end textarea)

pretend that the | is the cursor..
now if you click a button labled "break", the textarea should look like this:

(textarea)
blah blah blah |blah blah
(end textarea)

Is that right, Vulken?

Mark Hensler
If there is no answer on Google, then there is no question.

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

EDIT:# IT WORKS #:EDIT;

Yes Max that is what I am wanting to accomplish. I think Vincent has got it though. I don't know whether his will reset their text or not, but I am going to give it a shot. If that worx, man I'll be stoked!

Lemme know if you come up with anything else. I'll come back and let ya'll know how this code worked.

EDIT:

Unfortunately the link thing didn't seem to work. I tried it using the name of the form and the name of the textarea but upon click it just trys to hyperlink.
Maybe I did something wrong. Damn I was hoping that would work.

Unless there is something wrong with this code.

Add Text
[red]Problem[/red]

Missing the closing quotations!
EDIT;

VulKen
I will only stop at the song of 50 fat women

[Edited by VulKen on 08-25-2000 at 11:48 AM]

Pimpin like a pimp with an electrofied pimpin machine!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

so does it work now?

doesn't that only append to the textarea?
did you want it to insert as well?

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

It works exactly the way I wanted it to. Can't tell you what I'm using it for though...hehe.

But if you press it ten times it pastes it in ten times. You type something, press it, it pastes it...type some more..press it...pastes some more..etc.

It's perfect. Wish all code worked this well.

VulKen
ED = Editing Dysfunction

Pimpin like a pimp with an electrofied pimpin machine!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Vulken,

So...It just grows, huh? If that's all you want, you might consider putting the code in a function and adding setTimeout(), and then calling it from an onLoad event handler or some other innocuous event. That way it will grow without human intervention. (Cybersex indeed Smiling

Vinny

Where the world once stood
the blades of grass cut me still

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

No, Vincent..that's not all I wanted. But I can't reveal my overall plan..someone might steal it from me. But it is exactly what I wanted. Works especially well, considering I know as much about sex as I do about JavaScript..NULL! Besides where to put it!

VulKen
Just a Squirrel In a Whirl, Tryin' To Get a Nut

Pimpin like a pimp with an electrofied pimpin machine!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.