View Full Version : Onclick question.

02-22-2003, 03:48 AM
I have a problem with the onclick function, being a complete newbie at this, im not sure about the specifics.

Here's the problem:
<span id="signature"><br><br><br><a href="JavaScript:copyTo(document.all.signature)">Lala</a></span>

This seems simple enough, except that I want to activate this function when clicking a table, so:

<td bgcolor=#292422 onMouseOver="this.style.backgroundColor='#6F615D'; this.style.cursor='hand'" onMouseOut="this.style.backgroundColor=''" onClick="JavaScript:copyTo(document.all.signature)'"><span>Lala</span></td>

Unfortunatly it doesn't work, & i know the reason why :) . My question is whats the exact command I should use to activate the copyTo function through "onclick"?

Maybe something like "run.copyTo=('document.all.signature')" (doesnt work though)?

If i make the onclick function goto a link, i obviously cant do this:

It should be this:

So what should it be when running a function i made?

Any help greatly appreciated, thanks :)

02-22-2003, 04:03 AM
I'm not sure what you mean... are you talking about taking the value of the TD and having it write to another part of the page? 'Cause that's what I'm getting from this...

02-22-2003, 06:23 AM
Nono, ok let me use the examples again. Now to activate a link normally, one would just directly enter the HTML link into this bit here:

But that obviously doesnt work, & in order for it to, we would need to add in more details to activate the link:

I didnt figure out putting "window.location.href" by myself, it took several days of searching the web to find that out heh :) . So i have the same problem again, but this time doing it in another way, that is running my "copyTo" function when i click. So:


It doesnt work, & what im trying to figure out is specific details, for example something like this:



or something similar.

Thanks for your reply though :).

02-23-2003, 05:56 AM
Any help please?

Basically I want to copy a piece of text into the clipboard by planting the text within a table cell & clicking it as a link.

I have the clipboard part solved, & i can get the text into the clipboard either by clicking it directly using an <a> tag, or clicking it in an image tag.

But for simplicity's sake, id rather have a simple click-table-cell to get a text into a clipboard. Its faster, its responsive, its small & it can be adjusted easily.

Thanks again.

02-23-2003, 06:06 AM
Try dropping the "javascript:"


02-23-2003, 06:12 AM
Yes thanks, but i already tried that previously. Anyways i finally got it to work after seeing some examples lol :D

Here's the final code:
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td bgcolor=#292422 onMouseOver="this.style.backgroundColor='#6F615D'; this.style.cursor='hand'" onMouseOut="this.style.backgroundColor=''" onClick="return copyTo(document.all.test)"><span id="test">This text is copied to clipboard by clicking this table cell!! Yay!!</span></td></tr></table>

So basically i just entered a "return" in from of the function:
onClick="return copyTo(document.all.test)"

Can't believe how simple it was heh. Well thank you all so very much anyways :o

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum