Getting action info from popup to main window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DrKen

    Getting action info from popup to main window

    I need to have a user be able to click a link or button that brings
    up a popup window. When the user selects an item from the drop down
    list on the popup window (should I require only a click of the item or
    clicking a separate button like "continue"? ), I need the selection to
    show up in a text field on the main page. Yet, so far as I can tell,
    window.open() has no way to return any value. So how can I do this
    please? I'm sure it's a common thing to do. I see calendar popups do
    this all the time. Thanks.

    Ken
  • Tom Cole

    #2
    Re: Getting action info from popup to main window

    On Jun 26, 3:03 pm, DrKen <javaje...@yaho o.comwrote:
       I need to have a user be able to click a link or button that brings
    up a popup window.  When the user selects an item from the drop down
    list on the popup window (should I require only a click of the item or
    clicking a separate button like "continue"? ), I need the selection to
    show up in a text field on the main page.  Yet, so far as I can tell,
    window.open() has no way to return any value. So how can I do this
    please? I'm sure it's a common thing to do. I see calendar popups do
    this all the time.  Thanks.
    >
    Ken
    You can call window.opener.< function_name>.

    For example in your parent window you have a method named:

    setSelection(se lection) {
    //do something with selection value...
    }

    Then in your popup window you can call:

    var value = document.getEle mentById("someI D").value;
    window.opener.s etSelection(val ue);

    HTH.

    Comment

    • DrKen

      #3
      Re: Getting action info from popup to main window

      On Jun 26, 12:06 pm, Tom Cole <tco...@gmail.c omwrote:
      On Jun 26, 3:03 pm, DrKen <javaje...@yaho o.comwrote:
      >
      I need to have a user be able to click a link or button that brings
      up a popup window. When the user selects an item from the drop down
      list on the popup window (should I require only a click of the item or
      clicking a separate button like "continue"? ), I need the selection to
      show up in a text field on the main page. Yet, so far as I can tell,
      window.open() has no way to return any value. So how can I do this
      please? I'm sure it's a common thing to do. I see calendar popups do
      this all the time. Thanks.
      >
      Ken
      >
      You can call window.opener.< function_name>.
      >
      For example in your parent window you have a method named:
      >
      setSelection(se lection) {
      //do something with selection value...
      >
      }
      >
      Then in your popup window you can call:
      >
      var value = document.getEle mentById("someI D").value;
      window.opener.s etSelection(val ue);
      >
      HTH.
      Thanks. I was about to post an addendum. The main page has three
      fields that are essentially identical:
      Prior School 1:............. ......
      Prior School 2:............. ......
      Prior School 3:............. ......

      If the person clicks on a button to find the school for the first of
      these three, I need to fill in the first of the three. If the person
      clicks on the third box's link for the popup, I need to have the third
      row populated. Is there a way to do this without having to create
      three separate popup windows? Thanks.

      Ken

      Comment

      • SAM

        #4
        Re: Getting action info from popup to main window

        DrKen a écrit :
        >
        Thanks. I was about to post an addendum. The main page has three
        fields that are essentially identical:
        Prior School 1:............. ......
        Prior School 2:............. ......
        Prior School 3:............. ......
        >
        If the person clicks on a button to find the school for the first of
        these three, I need to fill in the first of the three. If the person
        clicks on the third box's link for the popup, I need to have the third
        row populated. Is there a way to do this without having to create
        three separate popup windows? Thanks.
        certainly, you can send in the same poppup all what you want, info 1 of
        school 1, info 3 of scholl 3 etc

        function pop(page) {
        // if popup doesn't exist or is closed
        if(typeof truc == 'undefined' || truc.closed)
        truc = window.open('', '','width=300,h eight=400'); // create it
        truc.location = page; // load in it the asked file
        truc.focus(); // bring it to front
        }

        In the file loaded in the popup

        <form
        action="javascr ipt:opener.docu ment.form1.scho ol_2.value=this .choice.value;o pener.focus()">
        Choose an option for School #2 : <select name="choice">
        <option value="1"first
        <option value="2"second
        </select><input type=submit>
        </form>


        That would have to work too with tabs
        --
        sm

        Comment

        Working...