Setting the value of window.opener from popup window name

T

Tony Farrell

Hi Everyone -

I have a data entry form that allows the user to click a button
and have that button popup a list of available values -

the code on the popup window uses the name of the form
to determine what field to populate on the opener...





function sendComment()

{
var x
x = document.canned_comment_form.lb1.value;
name = self.window.name;
if(name == "CMT1")
{
window.opener.document.main_form.comment_1_tb.value = x;
}

if(name == "CMT2")
{
window.opener.document.main_form.comment_2_tb.value = x;
}

if(name == "CMT3")
{
window.opener.document.main_form.comment_3_tb.value = x;
}

close();
}


Now - I have switched the data entry to a dynamic type of form -
where each section can have multiple comment boxes -


so the question i have is ....

how do i build the
window.opener.document.main_form.comment_3_tb.value = x;

line to replace the .comment_3_tb. with
the
name = self.window.name;


in other words -

i now have this line...
window.opener.document.main_form.comment_3_tb.value = x;

but i need it to be...
window.opener.document.main_form.[self.window.name].value = x;
(or whatever the syntax is correct)

please advise....

thanks
tony
 
R

Randy Webb

Tony said:
Hi Everyone -

i now have this line...
window.opener.document.main_form.comment_3_tb.value = x;

but i need it to be...
window.opener.document.main_form.[self.window.name].value = x;
(or whatever the syntax is correct)

window.opener.document.forms['main_form'].elements[self.window.name].value=x;
 

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

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top