SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    mom
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Need help with duplicating a script on the same page.

    Hello, I'm new here...

    I would like to ask for some help on duplicating this script so that I can have up to 10 or more copy boxes on one webpage.

    The script is a simple copy script but I'm not sure of to get it to copy from each different box on the same page. I put three boxes in the script below. Now I just need to get the scrip to copy the information from each box separately.

    Please help.

    Here is the script.


    <SCRIPT LANGUAGE="JavaScript">
    <!--

    var sp = window.location.hostname;

    function highlighttext() {
    document.cctext.text2copy.select(); document.cctext.text2copy.focus();
    }

    function copytext() {
    highlighttext();
    textRange = document.cctext.text2copy.createTextRange();
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Copy");
    }

    //-->
    </SCRIPT>


    <form name=cctext>

    <tr><td><p> </td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td class=body><b>Conversion Counter</b></td></tr>
    <tr><td class=body>To get started, please add the following HTML code to the
    appropriate page on your Web site.<br><img src=/images/signup/clear.gif height=4 width=1 alt=""><br><table cellpadding=3 cellspacing=0 border=0>
    <tr><td colspan=2><textarea name=text2copy cols=50 rows=10 wrap=virtual readonly>Just Testing the copy box</textarea></td></tr>
    <tr valign=top><td class=small> </td><td align=right>
    <input type="button" value="Copy" onClick="copytext();"></td></tr>
    </table></td></tr>
    </table></td></tr></form>

    <form name=cctext>

    <tr><td><p> </td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td class=body><b>Conversion Counter</b></td></tr>
    <tr><td class=body>To get started, please add the following HTML code to the
    appropriate page on your Web site.<br><img src=/images/signup/clear.gif height=4 width=1 alt=""><br><table cellpadding=3 cellspacing=0 border=0>
    <tr><td colspan=2><textarea name=text2copy cols=50 rows=10 wrap=virtual readonly>Just Testing the copy box</textarea></td></tr>
    <tr valign=top><td class=small> </td><td align=right>
    <input type="button" value="Copy" onClick="copytext();"></td></tr>
    </table></td></tr>
    </table></td></tr></form>

    <form name=cctext>

    <tr><td><p> </td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td class=body><b>Conversion Counter</b></td></tr>
    <tr><td class=body>To get started, please add the following HTML code to the
    appropriate page on your Web site.<br><img src=/images/signup/clear.gif height=4 width=1 alt=""><br><table cellpadding=3 cellspacing=0 border=0>
    <tr><td colspan=2><textarea name=text2copy cols=50 rows=10 wrap=virtual readonly>Just Testing the copy box</textarea></td></tr>
    <tr valign=top><td class=small> </td><td align=right>
    <input type="button" value="Copy" onClick="copytext();"></td></tr>
    </table></td></tr>
    </table></td></tr></form>


    Thanks

    RageDNA

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    copytext(obj) and highlighttext(obj)
    as functions, with obj being the input id.

    So you can use
    Code:
     onClick="copytext(textareaName);"
    with
    Code:
    function copytext(obj) {
    textRange = document.cctext.obj.createTextRange();
    .............
    }
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    SitePoint Member
    Join Date
    Oct 2003
    Location
    mom
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK cool were do I put the onClick="copytext(textareaName);" in the body tag?

    Not to sure I'm new to Java script.

    If at all possible could you edit and paste up a working script of more then two working boxes...please and thanks...

    I will try to get this to work.

    Thanks for helping..

  4. #4
    SitePoint Member
    Join Date
    Oct 2003
    Location
    mom
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I gave it a shot.... but did get it to work yet..

    This is what I got so far...



    <SCRIPT LANGUAGE="JavaScript">
    <!--

    var sp = window.location.hostname;

    function highlighttext() {
    document.cctext.text2copy.select(); document.cctext.text2copy.focus();
    }

    function copytext() {
    highlighttext();
    textRange = document.cctext.text2copy.createTextRange();
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Copy");
    }

    //-->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    <!--

    var sp = window.location.hostname;

    function highlighttext(box2) {
    document.cctext2.text2copy.select(box2); document.cctext2.text2copy.focus(box2);
    }

    function copytext(box2) {
    highlighttext(box2);
    textRange = document.cctext2.text2copy.createTextRange(box2);
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Copy");
    }

    //-->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">
    <!--

    var sp = window.location.hostname;

    function highlighttext(box3) {
    document.cctext3.text2copy.select(box3); document.cctext3.text2copy.focus(box3);
    }

    function copytext(box3) {
    highlighttext(box3);
    textRange = document.cctext3.text2copy.createTextRange(box3);
    textRange.execCommand("RemoveFormat");
    textRange.execCommand("Copy");
    }

    //-->
    </SCRIPT>
    </head>
    <body bgcolor=#FFFFFF marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 link=#0000FF alink=#FF0000 vlink=#0000FF>




    <form name=cctext>

    <tr><td><p>&nbsp;</td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td class=body><b>Conversion Counter</b></td></tr>
    <tr><td class=body>To get started, please add the following HTML code to the
    appropriate page on your Web site.<br><img src=/images/signup/clear.gif height=4 width=1 alt=""><br><table cellpadding=3 cellspacing=0 border=0>
    <tr><td colspan=2><textarea name=text2copy cols=50 rows=10 wrap=virtual readonly>Just Testing the copy box</textarea></td></tr>
    <tr valign=top><td class=small>&nbsp;</td><td align=right>
    <input type="button" value="Copy" onClick="copytext();"></td></tr>
    </table></td></tr>
    </table></td></tr></form>

    <tr><td><p>&nbsp;</td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td>
    <form name=cctext2>

    <tr><td><p>&nbsp;</td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td class=body><b>Conversion Counter</b></td></tr>
    <tr><td class=body>To get started, please add the following HTML code to the
    appropriate page on your Web site.<br><img src=/images/signup/clear.gif height=4 width=1 alt=""><br><table cellpadding=3 cellspacing=0 border=0>
    <tr><td colspan=2><textarea name=text2copy cols=50 rows=10 wrap=virtual readonly>Just Testing the copy box</textarea></td></tr>
    <tr valign=top><td class=small>&nbsp;</td><td align=right>
    <input type="button" value="Copy" onClick="copytext(box2);"></td></tr>
    </table></td></tr>
    </table></td></tr></form></table>
    </td></tr>

    <tr><td><p>&nbsp;</td></tr>


    <tr><td>&nbsp;<form name=cctext3>

    <tr><td><p>&nbsp;</td></tr>

    <tr><td><table cellpadding=8 cellspacing=0 border=0 width=650 bgcolor=#DCDCDC><tr><td class=body><b>Conversion Counter</b></td></tr>
    <tr><td class=body>To get started, please add the following HTML code to the
    appropriate page on your Web site.<br><img src=/images/signup/clear.gif height=4 width=1 alt=""><br><table cellpadding=3 cellspacing=0 border=0>
    <tr><td colspan=2><textarea name=text2copy cols=50 rows=10 wrap=virtual readonly>Just Testing the copy box</textarea></td></tr>
    <tr valign=top><td class=small>&nbsp;</td><td align=right>
    <input type="button" value="Copy" onClick="copytext(box3);"></td></tr>
    </table></td></tr>
    </table></td></tr></form></td></tr>


Bookmarks

Posting Permissions

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