Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Onclick question.

    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:
    onClick="lala.html'"

    It should be this:
    onClick="window.location.href=('lala.html')"

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

    Any help greatly appreciated, thanks

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

  • #3
    New Coder
    Join Date
    Nov 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    onClick="lala.html'"

    But that obviously doesnt work, & in order for it to, we would need to add in more details to activate the link:
    onClick="window.location.href=('lala.html')"

    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:

    onClick="JavaScript:copyTo(document.all.signature)"

    It doesnt work, & what im trying to figure out is specific details, for example something like this:
    run.copyTo="('document.all.signature')"

    or...

    runFunct.copyTo="('document.all.signature')"

    or something similar.


    Thanks for your reply though .

  • #4
    New Coder
    Join Date
    Nov 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try dropping the "javascript:"

    onClick="copyTo(document.all.signature);"

  • #6
    New Coder
    Join Date
    Nov 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes thanks, but i already tried that previously. Anyways i finally got it to work after seeing some examples lol

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •