window.opener, form.opener?

Discussion in 'Javascript' started by jojowebdev@gmail.com, Jul 14, 2006.

  1. Guest

    I see how the window.opener works, pretty neat in that the pop window
    knows the parent.

    Is there a property that also knows the form field parent?

    My function does not know which of the 3 select menus called it.

    What can I do?

    function onCarrierSelect() {
    //
    var frm = document.carrRequestForm.carrierList.selectedIndex
    var selectCar =
    document.carrRequestForm.carrierList.options[frm].text;
    alert(selectCar);
    if (window.opener && !window.opener.close)
    window.opener.document.form(x how make global?).nbcarrier(x how make
    global?).value = selectCar
    window.close();
    }


    p.s. as an aside I know the form field name, it is literally in the
    querystring, but that is ASP/vbscript and no way to get it into the
    jscript function...
    , Jul 14, 2006
    #1
    1. Advertising

  2. Guest

    Ok if I back up to the first function

    I may be able to get help writing a cookie, which I find unbelievably
    hard (compared to ASP)..
    I know the value of the form field in my function that is called first.
    I see it when I do alert(formEl.name); pretty cool.
    How do I put it in a cookie called "whichField"?

    CODE:

    function openCarrierWin(formEl) {
    var formElement = formEl.options
    if (formElement[formElement.selectedIndex].className == "newwin") {
    window.open((formElement[formElement.selectedIndex].value),
    "carrierWin", "resizable=1,height=625,width=700");
    // set cookie here with the value of
    alert(formEl.name);
    }
    else if (formElement[formElement.selectedIndex].value != "none") {
    return false;
    }
    }


    P.s. I have searched and searched on cookies but they are overly
    complex. I will take a look at the FAQ page I got earlier and see if
    your site explains cookies in javascript better. The thing is I dont
    want to write function after function for cookies. In asp it is soo
    easy. Response.Cookies("name") = "whichField" or something like that.
    Can someone show me javascript like that in one line?


    wrote:
    > I see how the window.opener works, pretty neat in that the pop window
    > knows the parent.
    >
    > Is there a property that also knows the form field parent?
    >
    > My function does not know which of the 3 select menus called it.
    >
    > What can I do?
    >
    > function onCarrierSelect() {
    > //
    > var frm = document.carrRequestForm.carrierList.selectedIndex
    > var selectCar =
    > document.carrRequestForm.carrierList.options[frm].text;
    > alert(selectCar);
    > if (window.opener && !window.opener.close)
    > window.opener.document.form(x how make global?).nbcarrier(x how make
    > global?).value = selectCar
    > window.close();
    > }
    >
    >
    > p.s. as an aside I know the form field name, it is literally in the
    > querystring, but that is ASP/vbscript and no way to get it into the
    > jscript function...
    , Jul 14, 2006
    #2
    1. Advertising

  3. Lee Guest

    Re: Ok if I back up to the first function

    said:
    >
    >I may be able to get help writing a cookie, which I find unbelievably
    >hard (compared to ASP)..
    >I know the value of the form field in my function that is called first.
    >I see it when I do alert(formEl.name); pretty cool.
    >How do I put it in a cookie called "whichField"?


    Just store a reference to the current field in a global variable
    in the parent window. Then your child can update the field as:

    window.opener.globalCurrentField.value="...";


    --
    Lee, Jul 14, 2006
    #3
  4. Randy Webb Guest

    said the following on 7/14/2006 10:38 AM:
    > I see how the window.opener works, pretty neat in that the pop window
    > knows the parent.
    >
    > Is there a property that also knows the form field parent?


    A form field's parent? That would be the form.

    > My function does not know which of the 3 select menus called it.


    Then tell it.

    > What can I do?


    Have your select element pass a reference to itself.

    > function onCarrierSelect() {


    function onCarrierSelect(selElem){

    And call it as such: onCarrierSelect(this)

    And then inside your function selElem will refer to the select element
    that called the function.

    > //
    > var frm = document.carrRequestForm.carrierList.selectedIndex


    frm refers to the selectedIndex of a Select element, frm is a misleading
    var name for it.

    > var selectCar =
    > document.carrRequestForm.carrierList.options[frm].text;
    > alert(selectCar);
    > if (window.opener && !window.opener.close)
    > window.opener.document.form(x how make global?).nbcarrier(x how make
    > global?).value = selectCar


    What form and what nbcarrier are you wanting to refer to?

    All form elements have a form property. selectElement.form refers to the
    parent form of the select list.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Jul 14, 2006
    #4
  5. Guest

    Re: Ok if I back up to the first function

    Just wondering..

    What I really need is to *NOT* change the .value OR .text but simply
    *change* the select menu to the correct value in the parent select
    menu.

    How do I do that please?


    function onCarrierSelect() {
    var frm = document.carrRequestForm.carrierList.selectedIndex
    var selectCar =
    document.carrRequestForm.carrierList.options[frm].text;
    var varEl = "<%=varElementName%>"
    // alert(varEl); // test variable
    if (window.opener && !window.opener.close)
    window.opener.document.form(0).<%=varElementName%>.value
    ="selectCar";
    window.close();
    }


    Thank you.
    Lee wrote:
    > said:
    > >
    > >I may be able to get help writing a cookie, which I find unbelievably
    > >hard (compared to ASP)..
    > >I know the value of the form field in my function that is called first.
    > >I see it when I do alert(formEl.name); pretty cool.
    > >How do I put it in a cookie called "whichField"?

    >
    > Just store a reference to the current field in a global variable
    > in the parent window. Then your child can update the field as:
    >
    > window.opener.globalCurrentField.value="...";
    >
    >
    > --
    , Jul 14, 2006
    #5
  6. Guest

    Re: Ok if I back up to the first function

    I tried both:
    window.opener.document.form(0).<%=varElementName%>.text =selectCar;
    and:
    I tried both
    window.opener.document.form(0).<%=varElementName%>.select =selectCar;

    But the thing is the Option I am attempting change does not exist, the
    value/text WEST BEND AUTO does not exist then how do I create one on
    the fly?

    Because in order for the parent page to then *truly* be able to submit
    the main form, dynamically this would *HAVE* to have been created.
    <option value='WEST BEND AUTO'>WEST BEND AUTO</option>

    Am I asking to much of a web application guys?



    P.s. I have values for varElementName AND selectCar.

    wrote:
    > Just wondering..
    >
    > What I really need is to *NOT* change the .value OR .text but simply
    > *change* the select menu to the correct value in the parent select
    > menu.
    >
    > How do I do that please?
    >
    >
    > function onCarrierSelect() {
    > var frm = document.carrRequestForm.carrierList.selectedIndex
    > var selectCar =
    > document.carrRequestForm.carrierList.options[frm].text;
    > var varEl = "<%=varElementName%>"
    > // alert(varEl); // test variable
    > if (window.opener && !window.opener.close)
    > window.opener.document.form(0).<%=varElementName%>.value
    > ="selectCar";
    > window.close();
    > }
    >
    >
    > Thank you.
    > Lee wrote:
    > > said:
    > > >
    > > >I may be able to get help writing a cookie, which I find unbelievably
    > > >hard (compared to ASP)..
    > > >I know the value of the form field in my function that is called first.
    > > >I see it when I do alert(formEl.name); pretty cool.
    > > >How do I put it in a cookie called "whichField"?

    > >
    > > Just store a reference to the current field in a global variable
    > > in the parent window. Then your child can update the field as:
    > >
    > > window.opener.globalCurrentField.value="...";
    > >
    > >
    > > --
    , Jul 14, 2006
    #6
    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. Steve Wark
    Replies:
    3
    Views:
    6,610
    bruce barker
    Oct 28, 2004
  2. =?Utf-8?B?Sko=?=
    Replies:
    1
    Views:
    2,205
    =?Utf-8?B?dmluYXk=?=
    Oct 12, 2004
  3. Andrew Bewley via DotNetMonster.com

    window to window communication (window.opener)

    Andrew Bewley via DotNetMonster.com, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,045
    Andrew Bewley via DotNetMonster.com
    Feb 3, 2005
  4. Urs Gubler
    Replies:
    0
    Views:
    151
    Urs Gubler
    Jul 2, 2003
  5. Yaron C.

    opener.opener ?

    Yaron C., Oct 30, 2003, in forum: Javascript
    Replies:
    4
    Views:
    210
    Yaron C.
    Nov 2, 2003
Loading...

Share This Page