简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM