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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    someone please help

    How do I copy multiple selects to a textarea?

    I'd like a button that adds/removes selections to/from the textarea

    Please help. It's for a PHP mailing list editor.

    I know very little about javascripting

    Thanks

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There are excelent javascript manuals on Internet, use google to find them
    rm -f /

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this should get you started on right track!
    Code:
    <script type="text/javascript">
      function copySelects(from, to) {
        var options = new Array;
        var select = document.getElementById(from);
        var textarea = document.getElementById(to);
        for (var i = 0; i < select.options.length; i++) {
          var option = select.options[i];
          if (option.selected) {
            options[options.length] = (option.value || option.innerHTML);
          }
        }
        textarea.value = options.join("; ");
      }
    </script>
    <select id="emails" size="10" multiple="true">
      <option>a@email.com</option>
      <option>b@email.com</option>
      <option>c@email.com</option>
    </select>
    <br/>
    <button onclick="copySelects('emails','email-textarea');">Copy</button>
    <br/>
    <textarea id="email-textarea" rows="10" cols="60"></textarea>
    Last edited by KC-Luck; 09-22-2005 at 10:15 PM.

  • #4
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks KC-Luck!!!

    That definitely helps!!

    I'm pulling addresses from mailing lists in PHP and I had textarea to textarea working, but this was trickier.

    Now all I have to do is send a <br> instead of a ; and figure out how to remove selections from the textarea.

    Thanks


  •  

    Posting Permissions

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