www.webdeveloper.com
Results 1 to 2 of 2

Thread: Fill parent text box from popup

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Fill parent text box from popup

    Hello everyone!

    I currently have code that will generate a random input into a text box within the same window upon a button click. Is there a way I can make this code populate a text box on a parent window if the code is contained within a popup? The program I'm using is encrypted with only limited access to template files or else I'd just include the code on the page itself.

    Here is my current code:
    Code:
    $(function() {
        $('#genID').click(function() {
            var SystemID = "";
            var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    
            for (var i = 0; i < 8; i++)
            SystemID += possible.charAt(Math.floor(Math.random() * possible.length));
            $('input[name="ID"]').val(SystemID);
        });
    });

  2. #2
    Join Date
    Jan 2013
    Posts
    2
    Here's the whole page actually. This text box is the one that it generates to, but I'd rather it generate to a parent box.

    Code:
    <html>
    <head>
    <script type="text/javascript" src="jquery.js"></script>
    <body>
    <script>
    $(function() {
        $('#genID').click(function() {
            var SystemID = "";
            var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    
            for (var i = 0; i < 8; i++)
            SystemID += possible.charAt(Math.floor(Math.random() * possible.length));
            $('input[name="ID"]').val(SystemID);
        });
    });
    </script>
    <input name="ID" type="text" id="id" onClick="this.select();" readonly="readonly">
    
    <button id="genID">Generate System ID</button>
    </body>
    
    </html>

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