469,331 Members | 4,122 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Passing variables beween windows

I know this looks like it has been answered 1000 times but I have a
slightly different problem.

I am dealing with forms in order to populate a database.
2 windows :
-Main window with my main form and the code to save the info into the
database.
There I also have a link to open a secondary window.
-Secondary window: checkbox (multiple choices) for the user to choose
from.

Obviously what I want is to capture the info from the checkboxes of
the secondary window ,send it to a variable within my main window and
then use that variable to send to my database.

the tricky part is that my main window is already open, and I don't
want to create a new one. I also don't want to show the user choices
again in any field, I just wants to be able to get the info into a
variable...

I have been searching around for a few days found some solutions but
not exactely what I need.

thanks for you help
Gabriel

Feb 28 '07 #1
7 1525
On Feb 28, 4:17 pm, "Cordouan" <gababa2...@yahoo.comwrote:
I know this looks like it has been answered 1000 times but I have a
slightly different problem.

I am dealing with forms in order to populate a database.
2 windows :
-Main window with my main form and the code to save the info into the
database.
There I also have a link to open a secondary window.
-Secondary window: checkbox (multiple choices) for the user to choose
from.

Obviously what I want is to capture the info from the checkboxes of
the secondary window ,send it to a variable within my main window and
then use that variable to send to my database.

the tricky part is that my main window is already open, and I don't
want to create a new one. I also don't want to show the user choices
again in any field, I just wants to be able to get the info into a
variable...

I have been searching around for a few days found some solutions but
not exactely what I need.

thanks for you help
Gabriel
please please somebody help...

Mar 1 '07 #2
ASM
Cordouan a écrit :
>>
I am dealing with forms in order to populate a database.
2 windows :
-Main window with my main form and the code to save the info into the
database.
There I also have a link to open a secondary window.
-Secondary window: checkbox (multiple choices) for the user to choose
from.

Obviously what I want is to capture the info from the checkboxes of
the secondary window ,send it to a variable within my main window and
then use that variable to send to my database.
jusque là ça va, assez fastoche.
quite easy

var mother = opener.document.myForm;
var daudhter = document.myForm;
var result = '';
for(var i=0; i<daughter.length; i++)
if(daughter[i].type == 'checkbox' && dughter[i].checked)
result += daughter{i].value+',';
mother.result.value = result;
self.close();
>the tricky part is that my main window is already open, and I don't
want to create a new one. I also don't want to show the user choices
again in any field, I just wants to be able to get the info into a
variable...
Why would you want to open a new window ?

Quite easy ---in popup when you press the validate button :

var daudhter = document.myForm;
var result = '';
for(var i=0; i<daughter.length; i++)
if(daughter[i].type == 'checkbox' && daughter[i].checked) {
result += daughter[i].value;
if(i<daughter.length-1) result += ',';
}
opener.myVariable = result;
/* or better :
opener.myFunction(result);
*/
self.close();
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 1 '07 #3
Merci stephane et son vieux mac !
Thanks a lot I am trying that ....

On Mar 1, 1:14 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
Cordouan a écrit :
I am dealing with forms in order to populate a database.
2 windows :
-Main window with my main form and the code to save the info into the
database.
There I also have a link to open a secondary window.
-Secondary window: checkbox (multiple choices) for the user to choose
from.
Obviously what I want is to capture the info from the checkboxes of
the secondary window ,send it to a variable within my main window and
then use that variable to send to my database.

jusque là ça va, assez fastoche.
quite easy

var mother = opener.document.myForm;
var daudhter = document.myForm;
var result = '';
for(var i=0; i<daughter.length; i++)
if(daughter[i].type == 'checkbox' && dughter[i].checked)
result += daughter{i].value+',';
mother.result.value = result;
self.close();
the tricky part is that my main window is already open, and I don't
want to create a new one. I also don't want to show the user choices
again in any field, I just wants to be able to get the info into a
variable...

Why would you want to open a new window ?

Quite easy ---in popup when you press the validate button :

var daudhter = document.myForm;
var result = '';
for(var i=0; i<daughter.length; i++)
if(daughter[i].type == 'checkbox' && daughter[i].checked) {
result += daughter[i].value;
if(i<daughter.length-1) result += ',';
}
opener.myVariable = result;
/* or better :
opener.myFunction(result);
*/
self.close();

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date

Mar 1 '07 #4
OK I am still having some problem here.
this does work great in my daughter window I am capturing the checkbox
fine into a variable, but it is still not updating the parent window.

I have tried (result being the value I want to transfer and Answer the
variable in the parent window that I am hoping to send to)
in the daughter:
-opener.Answer = result;
-opener.Answer.value = result;
while I have in the parent (just for testing)
document.write("ma value " + Answer);

Encore un petit coup de pouce stephane ?
Please a little more help for me ?
thanks

Mar 1 '07 #5
ASM
Cordouan a écrit :
OK I am still having some problem here.
this does work great in my daughter window I am capturing the checkbox
fine into a variable, but it is still not updating the parent window.
Que veux-tu dire par "updating" ?
Que veux-tu y modifier ?
(quel champ de quel formulaire ?)
I have tried (result being the value I want to transfer and Answer the
variable in the parent window that I am hoping to send to)
in the daughter:
-opener.Answer = result;
in mother window (parent window it is for framed pages)
function tellMe() {
forms[0].result.value = Answer;
}

in daughter (the popup) :
opener.Answer = result;
opener.tellMe();

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 2 '07 #6
Yes that works great.
Calling a function in the parent window makes it work.

MERCI
Ca me permet de repartir ca...

Thanks

Mar 2 '07 #7
ASM
Cordouan a écrit :
Yes that works great.
Calling a function in the parent window makes it work.

MERCI
Ca me permet de repartir ca...
encore plus simple et direct :

In mother window (main window) :

function tellMe(where, what) {
forms[0].elements[where].value = what;
}

In daughter (the popup) :

opener.tellMe('games', result);

and no more need specific mother variable(s) to communicate

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 2 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by domeceo | last post: by
6 posts views Thread by Scott Zabolotzky | last post: by
reply views Thread by Neelima Godugu | last post: by
3 posts views Thread by IntraRELY | last post: by
12 posts views Thread by Andrew Bullock | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.