Scope issue - JavaScript

software development


I have an issue with scope, can anyone give a suggestion? Here is the problem:

I am creating an online form, but before submitting it, I’d like to give users a chance to preview the form. The form has a “preview” button which upon being clicked calls a JavaScript function in which

  1. variables are set to reflect the user’s responses to the form
  2. opens a pop-up window, the code for which is stored in a different file. Here is the simplified function:

The pop-up window #includes the original file, and I was under the impession that I could call the variables from the included file if the call is being made from within JavaScript tags. However, I am getting a “variable undefined.” Here is that piece of code. The alert is just for testing purposes and will be changed once I figure out how to get the variable to show up.

<?php include("application1.php"); ?>

Actually, I would prefer to pull info from the form (which is in the first file) while in the second file, but I don’t see a way to do it; as far as I know, a window knows itself, and the name of a window that was opened from it… but is it possible to call from a newly opened window the parent window (to access the form which is in the parent window)?

Does it make sense, and is it feasible?

Thanks in advance for any suggestions.


problem solved.

I used window.opener to access the parent window (window.parent was not working for some reason, though from what I’ve read .opener and .parent should be the same thing) and then got the values straight from the form.