Onclick sending href volume to textarea?

JavaScript related questions should go here.
Post Reply
Jaami
Posts: 38
Joined: Wed Nov 23, 2011 11:22 pm
Location: GER

Onclick sending href volume to textarea?

Post by Jaami »

Ok, this should be something real easy, but i tried all kinda stuff and still cant manage to make it right.. :oops:

So i want to click on a link and send the volume of it to a textarea.

See:
31044045023.jpg
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Onclick sending href volume to textarea?

Post by Helx »

...

So you want to go to that link, and have the box 'selected' ?
Jaami
Posts: 38
Joined: Wed Nov 23, 2011 11:22 pm
Location: GER

Re: Onclick sending href volume to textarea?

Post by Jaami »

When i hover over a comment it shows me the link in the bottom left(i managed to do that already...). And when i click on the comment it sends the link to the textarea. The screenshot shows where i want to have the link of the comment...

101300014712124.jpg
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Onclick sending href volume to textarea?

Post by jacek »

If your <a> tag has the id of "link" and the <textarea> "area" then you can do this.

[syntax=javascript]document.getElementById('link').addEventListener('click', function(event){
event.preventDefault();

// this will get you the link.
alert(this.href);

// this will add it to the textarea
document.getElementById('area').appendChild(document.createTextNode(this.href));
}, false);[/syntax]
Hopefully anyway :P
Image
Post Reply