Send value from popup Window(Child) to Parent - javascript

I want to get a value on popup page, in one textbox, and send it to the parent window, to another textbox.
How to do that ?

Your question is not clear, but from what I deduce, you want to get the value of a textbox from the parent window in your child window.
You can do something like this -
var win = window.open('<Window URL>');
win.contentWindow.SetValueOfTextBox(parentWindowTextBoxValue);
Here win is the instance of the window you have opened.
You'll have to define SetValueOfTextBox function in the new window which you have opened. This function will accept a string and set that value to a textbox on that page. You just have to call that function from the parent window passing the value of the textbox to it.

Related

Multiple Windows using window.open() AND &apos;

I want to make sure that if a user clicks the button that opens a new window, that window is maintained if they click the button again. Meaning that I want the user to be able to hold multiple copies of the same window open even when opening new (of the same) ones.
At the moment I have this:
onclick="window.open(&apos;file.php?game=0&apos;, &apos;newwindow&apos; , &apos;width=920,height=740&apos;, &apos;resizable=0&apos;)
and I read another thread on here that I could just add a counter.
I did so with
$counter = 0; and then put , &apos;counter++$apos;, as an argument but that fails to load the entire page.
What am I missing?
$counter is a variable … but it looks like a PHP variable.
'counter++' is a string literal.
If you want a new window each time you run the script, just use the name _blank. There's no point to giving the window a name of its own unless you want to open multiple links in the same window.

I'm unable to clear the form input values in the newly opened window

In First Line of code, am opening a URL which loads a form.
var w = window.open(url);
In Second Line of code, am trying to erase all the input values of the
form in the newly opened window.
w.window.jQuery("#employer").find('input:text, input:password, input:file, select, textarea').val(' ')
In Third Line of code, am trying to print the form whose input values
have been erased.
w.window.print();
Using w.window.jQuery() doesn't make it search the document in w.window(). You need to pass that explicitly as an argument to jQuery:
jQuery("#employer", w.document).find(('input:text, input:password, input:file, select, textarea').val(' ');
Note that this will only work if the URL of the window is the same as the original page.

How to get value from one modal window textbox and put it to another textbox in another modal window?

I would like to ask you guys for a little help. I wanted to have my textbox in a modal to have the same value in another textbox in another modal window. The problem is I don't know how. I'm new in using modal windows. Hoping that someone can help me.
Illustration:
Modal window1 Modal Window 2
textbox1 textbox2
*textbox1.value must be equal to textbox2.value upon typing. so when the modal window 2 comes out it must have already a value which is the value of Modal window1 textbox1.
Well you can do this:
$('#textbox1').keydown(function(){
$('#textbox2').val($(this).val());
});
I presume that you have two textboxes with id textbox1 and textbox2.
I've attached keydown handler, which copies the textbox1's value and assigns it to textbox2 as you type.

how to pass radiobutton value from one jsp to another jsp

i have a jsp page on which i have a image, on click of that image i am opening a modal winwdow having radio buttons with corresponding value(another jsp)...
what i am trying to achieve is on selection of a radio button,assign it's value to a textbox which is on parent page...
Let me tell you that i am not submitting any form ...i just want to close this window and assign it's value to textbox on parent jsp, on selection of radio button
i tried to do it with session but couldn't figure out exact way...
any suggestions or inputs will be highly appriciated.
Thanks
Assume that in the parent window this is the text box that needs to be updated.
<input type="text" id="txtBoxDisplay" value=""/>
In parent window create a function to update the textbod with the new text
<script>
....
....
....
function updateTextBox(theTextString)
{
$("#txtBoxDisplay").val(theTextString); //assuming you are using jquery
document.getElementById('txtBoxDisplay').value = theTextString; // if not using jquery
}
</script>
In the child page/modal window use the following code to access the parent jsp function
window.opener.updateTextBox("Display this text in the parent text box");
You can also use
parent.updateTextBox("Display this text in the parent text box");
For more details see the following links
http://chiragrdarji.wordpress.com/2007/03/10/call-parent-windows-javascript-function-from-child-window-or-passing-data-from-child-window-to-parent-window-in-javascript/
http://www.rgagnon.com/jsdetails/js-0066.html
If you're not submitting any form, then the server obviously doesn't know anything about the selection you made in the modal window.
Use JavaScript to initialize the text field in the parent window with the selected radio. Since I gues you're using JQuery to open the dialog, then you shouldn't have any problem calling a JavaScript function defined in the parent window from the modal dialog.

Passing input value from parent window to popup window

I had made a parent window that includes a text box and hyperlink to open a PopUp Child JSP Page.
I wish to access the value entered in textbox on the Child JSP through request.getParameter method. How can I achieve this?
Just pass the value along as querystring in the URL of the popup window.
Assuming that you've a
<input type="text" id="foo">
you can pass it to the popup window as follows
var foo = document.getElementById('foo').value;
window.open('child.jsp?foo=' + encodeURIComponent(foo));
then you can access it in popup window as follows
<p>The value is ${param.foo}</p>

Categories