SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Copying Text

  1. #1
    SitePoint Addict Olate's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Copying Text

    Here is what I'd like to achieve:

    A developer / contractor has finished a job. He needs to fill out a little form for his money request.(where he types out the amount and what exactly he did). This is entered into a database using PHP. I want to be able to open the page with the request from my backend and open paypal in another window then, by clicking a link, the amouny, the job description and the email address of the user get copied over from the one window into the paypal window.

    Something like this http://www.echoecho.com/sample_parent.html but with PayPal.

    I can do the PHP stuff but I'm no good at Javascript - any pointers or help would be appreciated

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Olate,

    Have a look at this demo. There are two files:

    Main Form
    Code:
    <html>
    <head>
    <title>Main Form</title>
    <style type='text/css'>
    body {
      color:#000; background:#fff; margin:0; padding:10px;
      font-family:verdana,arial,sans-serif; font-size:14px;
    }
    </style>
    <script type='text/javascript'>
    var extWin, extWinUrl = 'extform.html', extFormName = 'xf1';
    window.onload = function() {
      extWinOpen();
    }
    function extWinOpen() {
      extWin = window.open(extWinUrl, 'extWin');
    }
    function doSubmit() {
      if (!extWin || extWin.closed) {
        extWinOpen();
      }
      if (extWin) {
        var mainF = document.forms['f1'];
        var extF = extWin.document.forms[extFormName];
        extF.user.value = mainF.user.value;
        extF.amt.value = mainF.amt.value;
        extF.desc.value = mainF.desc.value;
        extWin.focus();
      }
    }
    </script>
    </head>
    <body>
    <p>Pass values to a form in another window.</p>
    <p><b>f1</b></p>
    <form name='f1' onsubmit='doSubmit(); return false;'>
    User <input type='text' name='user' value=''><br>
    Amount <input type='text' name='amt' value=''><br>
    Description <input type='text' name='desc' value=''><br>
    <input type='submit' value='GO'>
    </form>
    </body>
    </html>
    External Form
    Code:
    <html>
    <head>
    <title>External Form</title>
    <style type='text/css'>
    body {
      color:#000; background:#fff; margin:0; padding:10px;
      font-family:verdana,arial,sans-serif; font-size:14px;
    }
    </style>
    </head>
    <body>
    <p>Receive values from a form in another window.</p>
    <p><b>xf1</b></p>
    <form name='xf1' onsubmit='return false'>
    User <input type='text' name='user' value=''><br>
    Amount <input type='text' name='amt' value=''><br>
    Description <input type='text' name='desc' value=''><br>
    </form>
    </body>
    </html>


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
  •