Setting the value of window.opener from popup window name

Discussion in 'Javascript' started by Tony Farrell, May 10, 2004.

  1. Tony Farrell

    Tony Farrell Guest

    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
    Tony Farrell, May 10, 2004
    #1
    1. Advertising

  2. Tony Farrell

    Randy Webb Guest

    Tony Farrell wrote:

    > Hi Everyone -


    <snip>

    >
    > 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;




    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/
    Randy Webb, May 10, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sko=?=
    Replies:
    1
    Views:
    2,194
    =?Utf-8?B?dmluYXk=?=
    Oct 12, 2004
  2. Matt Jensen
    Replies:
    1
    Views:
    5,213
    Matt Jensen
    Dec 16, 2005
  3. Timo
    Replies:
    6
    Views:
    556
    Alexey Smirnov
    Jan 14, 2008
  4. Urs Gubler
    Replies:
    0
    Views:
    140
    Urs Gubler
    Jul 2, 2003
  5. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    272
Loading...

Share This Page