www.webdeveloper.com
Results 1 to 4 of 4

Thread: help: i need a script that will copy the label of the button when clicked

  1. #1
    Join Date
    May 2006
    Posts
    16

    Exclamation help: i need a script that will copy the label of the button when clicked

    Hi gurus,

    Hi guys, I am in the process of making a troubleshooter site for my company.
    It employs buttons to go through each troubleshooting step.
    each button indicates what the troublehooting step is.

    i need a script that will copy the text on the button when clicked, then if possible transfer it to another text box/area in a page that will show up when all steps have been taken, kinda like a step summary

    maybe just ignore the summary part, hehehe...
    just the script that will copy the text label of the button...

    thanks...

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,678
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function Add(obj,tar){
     var tar=document.getElementById(tar);
     var txt=obj.value+',';
     if (tar.innerHTML.match(txt)){
      tar.innerHTML=tar.innerHTML.replace(txt,'');
     }
     else {
      tar.innerHTML+=txt;
     }
    }
    //-->
    </script>
    
    </head>
    
    <body>
    <input type="button" name="" value="Step 1" onclick="Add(this,'Summary');" >
    <input type="button" name="" value="Step 2" onclick="Add(this,'Summary');" >
    
    <div id="Summary" >
    <br>
    </div>
    </body>
    
    </html>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    May 2006
    Posts
    16
    thanks dude,

    its up to me then...

    one question, can i replace "summary"?
    and then just change the div id?

    will it have an effect on the code?

    once again thanks

  4. #4
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,678
    ID names must be unique and start with an apha charator or $

    the code is generic to allow any ID name to be passed to the function
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles