Passing variables beween windows

C

Cordouan

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
 
C

Cordouan

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...
 
A

ASM

Cordouan a écrit :
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.type == 'checkbox' && dughter.checked)
result += daughter{i].value+',';
mother.result.value = result;
self.close();

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.type == 'checkbox' && daughter.checked) {
result += daughter.value;
if(i<daughter.length-1) result += ',';
}
opener.myVariable = result;
/* or better :
opener.myFunction(result);
*/
self.close();
 
C

Cordouan

Merci stephane et son vieux mac !
Thanks a lot I am trying that ....

Cordouan a écrit :



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.type == 'checkbox' && dughter.checked)
result += daughter{i].value+',';
mother.result.value = result;
self.close();

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.type == 'checkbox' && daughter.checked) {
result += daughter.value;
if(i<daughter.length-1) result += ',';
}
opener.myVariable = result;
/* or better :
opener.myFunction(result);
*/
self.close();
 
C

Cordouan

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
 
A

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();
 
C

Cordouan

Yes that works great.
Calling a function in the parent window makes it work.

MERCI
Ca me permet de repartir ca...

Thanks
 
A

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top