SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Tricky question (for me)

    Hey,
    What I'm looking for is how I would go about doing this. I have my main window, and a button to test a user variable they enter in a form. Here's an example -
    PHP Code:
    <form method='post' action='file.php'>
    <
    input type='text' name='field' style='width: 150px' />&nbsp;<button name='button' onClick='??'>Test</button><br />
    <
    input type='submit' name='submit' value='Submit' /> 
    The user types a value into field and then clicks button and a new window opens, does some PHP, returns either true or false, exits pop-up window, and then a little tick or cross appears nexy to field to indicate whether the value worked or not.

    Thanks heaps

  2. #2
    SitePoint Enthusiast Analyser's Avatar
    Join Date
    Oct 2002
    Location
    Delft, The Netherlands
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a proof-of-concept I slapped together in about twenty minutes:

    Code:
    <html>
    <head>
    <script>
    function checkvalue() {
      var w = window.open('<?php echo $PHP_SELF; ?>?a='+escape(document.myform.mytext.value), 'popup_win');
    }
    </script>
    <?php
    
    if (empty($a)) {
    ?>
    <body>
    <p>A value of <b>42</b> turns the checkbox on, any other value will turn it off.</p>
    <form name="myform">
    <input type="checkbox" id="mybox" />
    <input type="text" id="mytext" size="20" />
    <input type="button" id="mybutton" value="Click Me!" onclick="checkvalue()" />
    </form>
    <?php
    } else {
    	echo '<body onload="window.close()">';
    	echo "<script>\nwindow.opener.document.myform.mybox.checked = ";
    	echo ($a == "42") ? "1" : "0";
    	echo ";\n</script>\n";
    }
    ?>
    </body>
    </html>
    Enjoy
    "A poor programmer is he who blames his tools."
    http://analyser.oli.tudelft.nl/

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Thanks for that! I had to change it a little to use the $_GET array and it works


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
  •