Return value of popup window

I hope someone can be kind to help me with this problem.

What I'm trying to do, I return the value from the popup to the parent window that launched it using javascript.

What I tried causes (as read on different sites)

window.opener.document.forms[0].textField.value = 'value'

but while it does not cause any errors, it does not change the value of the field.

I tried to find a solution on the net for this, but where there are so many sites related to β€œpop up return value” in google, the results related to 2000, many seem to conflict with each other, so I'm a bit confused.

Ideally, I would prefer the popup to wait for a decision to be made (yes or no) and have a true or false value returned to the calling function from the parent window. As a reason for this, I want to have a form using onsubmit to call the javascript function to confirm that the weather does not continue. I used the dialog box to return the true false value, but now I'm trying to do this with a popup to include images and other information.

Hopefully I explained it well enough and someone can help me with the solution.

Thank you for your time.

+6
source share
5 answers

, ... - ( ), "val"...

 <script language="javascript">
    function GetRowValue(val)
    {
        // hardcoded value used to minimize the code.
        // ControlID can instead be passed as query string to the popup window
        window.opener.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value = val;
        window.close();

    }

    </script>
+4
+2

var answer = window.open(<your page and other arguments>)
if (answer == 1)
      do some thing

window.returnValue = 1;
+1

:

window.opener.document.getElementById("sizeId" + rn).value

, .

0
source

If you want to return a value from a dialog box, you can achieve this using the callback function and the window.unload event. Be sure to check out this link . This is a good example.

0
source

All Articles