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
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts

    How to handle multiple popup windows

    I have a popup window that is working ok but now I want to popup a second window exactly like it. So I modified the popup window JS code and now I can do that and get the 2nd window open - however - the two windows seem to be using the same global $_SESSION vars and that I think is the problem I'm having. The windows also do an auto refresh every minute to update the display from a database.

    In the window I have a drop down list where I can select a MySQL filter value and display data based on that selected filter. When I select an item from the list and click submit, my window.php script calls window_dispatcher.php and that dispatcher script assigns my list selection into a $_SESSION var ($_SESSION["filter_value"]) and then calls window.php again.

    In window.php I use that $_SESSION["filter_value"] to control the MySQL filter sql statement.

    So, here's the problem: with two windows open, when I set a filter in one window, when the other window refreshes, it then assumes the first windows filter setting!. I was trying to be able to open multiple windows and set different filters in each one and have them refresh independently, but I think my $_SESSION vars, being global, are ending up being 'sync'd' when each window refreshes.

    So I thought well I could just eliminate the globals vars but then I don't know how to select from a drop down list and then save that value so its used when the window.php file is called again from my dispatcher script.

    Maybe there is another way to do that but I've always used the main script/dispatcher script model in my php coding.

    I hope I have been clear in trying to describe my problem.
    Thanks
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    PHP couldn't care less how many windows you have running. As long as you have an identifier for you're session, it will use it.
    The only solution is to provide something unique for each window - a get value. This can be what you're looking to use or something to help control the session flows by blocking them into multi-dimensional values instead of singular ones. It's really the only way to look at controlling two windows independant of each other but still share the same session.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    I found the following structure that I think need to use. The php script calling itself instead of the main/dispatcher structure I'm currently using.

    But the $pullemail var is the key in this structure. If I set its value and then click submit, it's used and would send out the email, but then when the form re-displays, its value is empty again. I need to be able to save the value for reuse in the main form again after the submit.

    Maybe I do have to use an array var structure of some kind.

    PHP Code:
    <?php
    if ($_POST['submit']) {

    $pullemail $_POST['email'];
    $pullmess $_POST['message'];

    $to "someone@example.com";
    $subject "Test mail";
    $message "$pullmess";
    $from "$pullemail";
    $headers "From: $from";
    //mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    }
    else {
    ?>
    <form method='post' action='test.php'>
      Email: <input name='email' value="<?php echo $pullemail?>" type='text' /><br />
      Subject: <input name='subject' type='text' /><br />
      Message:<br />
      <textarea name='message' rows='15' cols='40'>
      </textarea><br />
      <input type='submit' />
      </form>
    <?php
    }
    ?>
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #4
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    The solution was to use both _GETs and _POSTs in the single php file.

    In the refresh meta tag I put this

    PHP Code:
    <META http-equiv="Refresh" content="10; URL=window.php?flag=auto_refresh&emp_id=<?php echo $emp_id?>">
    $emp_id holds the drop down list item selected. I selected from the list and then using an OnChange() JS event, it updates to make the database filter on that item.

    Then when the meta refresh kicks in, I pass the drop down list item in a _GET so it continues to use the same value.
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com


  •  

    Posting Permissions

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