Setting variables in another window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adeon

    #1

    Setting variables in another window

    Hi,

    I'm trying to create specific pop'up window (for product category
    selection), but in JS I'm a newbie
    and some problem occured, so I have a question:

    Is it possible in main window (that opens a popup) to set in popup window:
    1. global variables
    2. form fields

    For example, I'm opening popup window like below:
    categories=wind ow.open(address ,"categories"," scrollbars=no,h eight=400,width =
    600");

    Then I try to set global variable in popup window:
    categories.glob al_variable = 1; //no effect

    Or try to set form field:
    categories.docu ment.some_form. some_filed.valu e = "some value"; //no effect

    If none of above won't work, how could I pass some data to another window
    using JS?

    Greets
    adeon



  • Lasse Reichstein Nielsen

    #2
    Re: Setting variables in another window

    "adeon" <adeon@tlen.p l> writes:
    [color=blue]
    > Is it possible in main window (that opens a popup) to set in popup window:
    > 1. global variables
    > 2. form fields[/color]

    Yes.
    [color=blue]
    > For example, I'm opening popup window like below:
    > categories=wind ow.open(address ,"categories"," scrollbars=no,h eight=400,width =
    > 600");
    >
    > Then I try to set global variable in popup window:
    > categories.glob al_variable = 1; //no effect
    >
    > Or try to set form field:
    > categories.docu ment.some_form. some_filed.valu e = "some value"; //no effect[/color]

    You have to wait for the page in the popup window to load.
    [color=blue]
    > If none of above won't work, how could I pass some data to another window
    > using JS?[/color]

    You are doing it correctly, but it only works when the page is loaded
    (or at least has loaded to the point where the form and form field
    exists).

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Adam Dyga

      #3
      Re: Setting variables in another window

      Lasse Reichstein Nielsen wrote:
      [color=blue]
      > You are doing it correctly, but it only works when the page is loaded
      > (or at least has loaded to the point where the form and form field
      > exists).[/color]

      So, how can I check if form field has been already loaded?


      --
      Greets
      adeon

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Setting variables in another window

        Adam Dyga wrote:
        [color=blue]
        > Lasse Reichstein Nielsen wrote:[color=green]
        >> You are doing it correctly, but it only works when the page is loaded
        >> (or at least has loaded to the point where the form and form field
        >> exists).[/color]
        >
        > So, how can I check if form field has been already loaded?[/color]

        To be sure:

        if (referenceToWin dow
        && !referenceToWin dow.closed
        && referenceToWind ow.document
        && referenceToWind ow.document.for ms
        && referenceToWind ow.document.for ms["foo"]
        && referenceToWind ow.document.for ms["foo"].elements
        && referenceToWind ow.document.for ms["foo"].elements["bar"]
        && typeof
        referenceToWind ow.document.for ms["foo"].elements["bar"].value !=
        "undefined" )
        {
        /*
        * do something with
        * referenceToWind ow.document.for ms["foo"].elements["bar"].value
        */
        }

        Untested, HTH.


        PointedEars

        Comment

        Working...