473,409 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

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=window.open(address,"categories","scrol lbars=no,height=400,width=
600");

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

Or try to set form field:
categories.document.some_form.some_filed.value = "some value"; //no effect

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

Greets
adeon

Jul 20 '05 #1
3 4165
"adeon" <ad***@tlen.pl> writes:
Is it possible in main window (that opens a popup) to set in popup window:
1. global variables
2. form fields
Yes.
For example, I'm opening popup window like below:
categories=window.open(address,"categories","scrol lbars=no,height=400,width=
600");

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

Or try to set form field:
categories.document.some_form.some_filed.value = "some value"; //no effect
You have to wait for the page in the popup window to load.
If none of above won't work, how could I pass some data to another window
using JS?


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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
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).


So, how can I check if form field has been already loaded?
--
Greets
adeon
Jul 20 '05 #3
Adam Dyga wrote:
Lasse Reichstein Nielsen wrote:
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).


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


To be sure:

if (referenceToWindow
&& !referenceToWindow.closed
&& referenceToWindow.document
&& referenceToWindow.document.forms
&& referenceToWindow.document.forms["foo"]
&& referenceToWindow.document.forms["foo"].elements
&& referenceToWindow.document.forms["foo"].elements["bar"]
&& typeof
referenceToWindow.document.forms["foo"].elements["bar"].value !=
"undefined")
{
/*
* do something with
* referenceToWindow.document.forms["foo"].elements["bar"].value
*/
}

Untested, HTH.
PointedEars
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mosher | last post by:
Hello all, is there any way to send php variables to another popup html window? I just want users to be able to click on a hyperlink like this... e.g., <a target=new...
9
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
2
by: lawrence | last post by:
I thought I was fighting a PHP problem, so I asked about this on a PHP list, but they felt it was a Javascript problem, so I'm reposting a bit of the debate here. Could this Javascript, below,...
2
by: Hasan Ammar | last post by:
Is it possible to set up hotkeys using onkeypress? I know it can be done with the usual alphanumeric keys, but what about function keys? or using ctrl/alt combinations? Does anybody have a...
7
by: danny | last post by:
Hello everyone, How can I go about setting a number of variables using a table which will have the variable names to be declared in one table. The data to be assigned will reside in another. As...
2
by: Chris | last post by:
Hi, I'm new to ASP.Net and Crystal but I've been playing with some samples and have run into a problem. If I put all my code into the Page_Init sub of a single form and run that form, the...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: phoenix917 | last post by:
I have been working on this code for 5 days... I have read multiple tutorials and looked at various code. This is my third forum try... :) My instructor refuses to help me. I think it's because...
1
by: jwestin | last post by:
Hi, I have a main window that opens another window, that i would like to have as "datastorage". The second window will have variables that should be set from the first window. Finally I would...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.