Results 1 to 4 of 4

Thread: dynamically populate textarea from first webform

  1. #1
    Join Date
    Aug 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default dynamically populate textarea from first webform

    I have 2 webforms, can one form with checkboxes populate a textarea on the second webform with the names of the checkboxes selected?

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there superbarbs,

    and a warm welcome to these forums.

    try it like this...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script type="text/javascript">
    
    window.onload=function() {
       df=document.forms;
       inp=df[0].getElementsByTagName('input');
    for(c=0;c<inp.length;c++) {
    if(inp[c].type=='checkbox') {
       inp[c].onclick=function() {
    if(this.checked==true){
       df[1][0].value+=this.name+' ';
    }
    else {
       df[1][0].value=df[1][0].value.replace(this.name+' ','');
         }
        }
       }
      }
     }
    
    </script>
    
    </head>
    <body>
    
    <form action="#">
     <div>
       <input type="checkbox" name="foo"/>
       <input type="checkbox" name="blah"/>
       <input type="checkbox" name="dodah"/>
     </div>
    </form>
    
    <form action="#">
     <div>
       <textarea cols="20" rows="3"></textarea>
     </div>
    </form>
    
    </body>
    </html>
    coothead
    Last edited by coothead; 11-27-2006 at 06:24 PM. Reason: typing error

  3. #3
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi CootHead,
    This is a very interesting script. If I want to send the selected info in the text area to an email address, how do i add the "send" button to the script?

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    JavaScript can't send email (from Client-side). But you can use JavaScript(Client-side) and Server-side (ASP or PHP) to send information.

    Check this article

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
  •