Passing input value from parent window to popup window - javascript

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>

Related

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.

CKEditor: set value of an input field in dialog window of plugin "image"

How can i get instances of plugin dialog window contents elemets to manipulate its for example set the value of an input field in dialog window of plugin "image"?
Use the following to retrieve the native DOM element of a field (already opened dialog):
CKEDITOR.dialog.getCurrent().getContentElement( 'info', 'txtUrl' ).getInputElement().$
To dynamically set field's value when the dialog is shown, please refer to my previous answer.

Passing ID parameter to an aspx modal window

I have a repeater control that contains a hyperlink which the user will click to launch a custom aspx modal window. The hyperlink contains the "record id" value.
The user clicks the hyperlink, the code passes from code behind to javascript, which launches the custom aspx window.
How do I pass the record id parameter from javascript function so that the aspx modal window being launched can retreieve it, and run a sql query with that value.
I am open to creating a session value, a hidden html control (I tried the hidden control, but was not able to pass the value) or any other options.
Any suggestions?
From what you write, the most obvious solution would be to pass the ID as the part of the address. Like:
<ItemTemplate>
<a href="javascript:ChildWindowUrl?ID=<'%# ((MyEntityType)Container.DataItem).ID %'> >child window</a>
</ItemTemplate>

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.

Send value from popup Window(Child) to Parent

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.

Categories