PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Dec 12, 2018 12:56 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Jun 04, 2002 5:48 pm 
Offline
Forum Contributor
User avatar

Joined: Mon May 06, 2002 3:42 pm
Posts: 223
Location: Colorado
I'm looking for a quick and dirty way to pass a form's variables to a popup window when the form's button is clicked. I'm creating a report based on filters that the end user chooses, and the report will be displayed in the popup window.

I already know how to create the window with JS. I'm stuck on how to handle the "action=" event in the form. The code follows:
Syntax: [ Download ] [ Hide ]
<SCRIPT LANGUAGE="JavaScript">
     <!-- Begin
     function openkeywin(theURL,winName,features) {
         window.open(theURL,winName,features);
     }
    //-->
</script>

//...other PHP formatting code up to here

echo "<form name='report_form' method='POST' action='issue_summary_disp.php'>";

//...remaining form stuff

echo "<font size='1' class='small'><input type='submit' name='Submit' value='Submit'>";
echo "</form>";


issue_summary_disp.php is the page that will be displayed in the popup window. Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 04, 2002 9:08 pm 
Offline
Moderator
User avatar

Joined: Tue Apr 23, 2002 6:00 pm
Posts: 531
Location: Lowell, MA USA
i think i saw this somewhere once: put a target attrib. in the form tag. whilist not at all (X)HTML valid, it is worth a shot.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 04, 2002 9:17 pm 
Offline
Site Admin

Joined: Thu Apr 18, 2002 3:14 pm
Posts: 1767
Location: Montreal, CA
I did this once:

Syntax: [ Download ] [ Hide ]
<script language=JavaScript>

function signup_checkusername(){

var gt = unescape('%3e');
var popup = null;
var over = 'Launch Pop-up Navigator';
var username = document.signupform.TextI_UserName.value;
if ( username == "" ) return false;
gourl = 'check_username.php?username=' + username;
  popup = window.open('', 'popupcheck', 'width=200,height=100,resizable=0,scrollbars=0,statusbar=0,menubar=0');
  if (popup != null) {
   if (popup.opener == null) {popup.opener = self;}
   popup.location.href = gourl;
 } }
</script>


And then:

Syntax: [ Download ] [ Hide ]
<a href=javascript:void(0) onClick="signup_checkusername();">
        <img src="images/check_button.gif" alt="Click here to check username availability" border="0" />
        </a>


That is what I did. You can find it on this page: http://www.originalpoker.com/cust_signup.php

It simply checks the username to make sure it's not already taken, but it is basiclaly what you want, I guess.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 05, 2002 9:23 am 
Offline
Forum Contributor
User avatar

Joined: Mon May 06, 2002 3:42 pm
Posts: 223
Location: Colorado
Hey Jason...so, you basically had to set the variables that would be passed to the new window within the JS function and then pass them to the new window? And, use a link instead of a submit button?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 06, 2002 11:55 am 
Offline
Forum Contributor
User avatar

Joined: Mon May 06, 2002 3:42 pm
Posts: 223
Location: Colorado
I've tried the above method, with a few modifications, but the variables still don't seem to be getting passed to the popup window. The JS follows:
Syntax: [ Download ] [ Hide ]
<SCRIPT LANGUAGE="JavaScript">
        <!-- Begin
                function report_popup() {
                        var popup = null;
                        var cat_id = document.report_form.cat_id.value;
                        var resolution = document.report_form.resolution.value;
                        gourl = 'issue_summary_disp.php?cat_id = ' + cat_id + '&resolution = ' + resolution;
                        popup = window.open('', 'reportdisp', 'width=680, height=800, toolbar=0, status=0, menubar=0, location=0, scrollbars=1, resizable=0, directories=0');
                        if (popup != null) {
                                if (popup.opener == null) {
                                        popup.opener = self;
                                }
                                popup.location.href = gourl;
                        }
                }
        //-->
</script>


My form looks like:
Syntax: [ Download ] [ Hide ]
//input form for the search
echo "<table width='350' border='0' cellspacing='0' cellpadding='0'>";
        echo "<form name='report_form' method='POST' onsubmit='return report_popup();'>";
                echo "<input type='hidden' name='go' value='1'>";
        echo "<tr bordercolor='#ffffff'>";
                echo "<td><font class='small'> Filter By Application: </font></td>";
                echo "<td><font class='small'> Filter By Category: </font></td>";
        echo "</tr>";
        echo "<tr>";
               
                //generate applications drop down
                $query_apps = "SELECT * FROM application ORDER BY app_name";
                $result_apps = mysql_query($query_apps);
                if(!$result_apps) {
                        echo "<td>Could not get applications!</td>";
                        exit;
                }
                if(mysql_num_rows($result_apps) == 0) {
                        echo "<td valign='top' bordercolor='#ffffff'><font class='small'>No applications setup - go to the <a href='app_entry.php'>Applications</a> page to setup.</font></td>";
                        exit;
                }
                else {
                        echo "<td valign='top' bordercolor='#ffffff'>";
                                echo "<select name='app_idї]' size='5' multiple>";
                                while($row = mysql_fetch_array($result_apps)) {
                                        echo "<option value='".$rowї0]."' selected>".$rowї1]."</option>";
                                }
                                echo "</select>";
                        echo "</td>";
                }
               
                //generate category drop down
                $query_cats = "SELECT * FROM categories ORDER BY cat_name";
                $result_cats = mysql_query($query_cats) or die("Could not get categories - please try again later.");
               
                if(mysql_num_rows($result_cats) == 0) {
                        echo "<td valign='top' bordercolor='#ffffff' width='35%'><font class='small'>No categories setup.</font></td>";
                        exit;
                }
                else {
                        echo "<td valign='top' bordercolor='#ffffff'><font class='small'>";
                                echo "<select name='cat_id' size='1'>";
                                while($row = mysql_fetch_array($result_cats)) {
                                        echo "<option value='".$rowї0]."'>".$rowї1]."</option>";
                                }
                                        echo "<option value='all_cats' selected>All Categories</option>";
                                echo "</select>";
                        echo "</font></td>";
                }
               
        echo "</tr>";
        echo "<tr>";
                echo "<td> </td>";
        echo "</tr>";
        echo "<tr>";
                echo "<td colspan='2'><font class='small'><input type='checkbox' name='resolution' value='T'>Include Resolution</font></td>";
        echo "</tr>";
        echo "<tr>";
                echo "<td> </td>";
        echo "</tr>";
        echo "<tr>";
                echo "<td>ї <a href="javascript:;" onclick="report_popup();">Show Report</a> ]</td>";
        echo "</tr>";
        echo "<tr bordercolor='#ffffff'>";
                echo "<td bordercolor='#ffffff' colspan='2'>";
                        echo "<font size='1' class='small'><input type='submit' name='Submit' value='Submit'>";
                        echo "</form>";
                echo "</td>";
        echo "</tr>";
echo "</table>";


The popup window is being launched successfully, but the variables don't seem to be getting passed along. Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 07, 2002 2:30 am 
Offline
Forum Regular
User avatar

Joined: Fri May 03, 2002 3:33 am
Posts: 512
Location: Edinburgh, Scotland
Which browser? there is a difference in the way you reference fields between Netscape and IE within javascript.

Try putting an alert in your javascript function to display the variables you have set.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 07, 2002 9:04 am 
Offline
Forum Contributor
User avatar

Joined: Mon May 06, 2002 3:42 pm
Posts: 223
Location: Colorado
I'm primarily using the latest version of IE, although I will have users on both Mac and Windows platforms using the latest versions of IE and NS.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 10, 2002 3:11 pm 
Offline
Forum Contributor
User avatar

Joined: Mon May 06, 2002 3:42 pm
Posts: 223
Location: Colorado
I'm posting a reply to bump this topic back up...I'm still struggling with this. Can anyone give me a hand?

My sticking point is that I have a multiple select box in the form, in addition to other standard elements, so an array is also being passed. I can't seem to set the variables correctly so that they get passed to the popup window.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 11, 2002 10:19 am 
Offline
Forum Contributor
User avatar

Joined: Mon May 06, 2002 3:42 pm
Posts: 223
Location: Colorado
Stop the press! I finally got it...thought I'd post it here so other folks might benefit in the future. It's very simple, really...just setup the <form> tag like so:
Syntax: [ Download ] [ Hide ]
echo "&lt;form name='report_form' method='POST' action='page_to_display_in_popup.php' target='myWin' onsubmit='javascript:myWin = window.open("", this.target, "width=680, height=800, toolbar=0, status=0, menubar=0, location=0, scrollbars=1, resizable=0, directories=0")'&gt;";

Of course, you can specify whatever window features you want (i.e. width=, height=, toolbar=, etc.).

Best,

Crashin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group