2011-03-23 171 views
0

我有一个jsp页面,在其上我有一个图像,单击该图像时打开一个具有相应值(另一个jsp)的单选按钮的模式winwdow ...如何将单选按钮的值从一个jsp传递给另一个jsp

我试图做到的,是在一个电台按钮的选择,分配给它的价值,是一个文本框,这是父页...

让我告诉你,我没有提交任何形式的...我只想关闭此窗口,并将其值分配给父母jsp上的文本框,选择单选按钮

我试图用session进行操作,采取行动的方式...

任何建议或意见将高度appriciated。 谢谢

回答

1

假设在父窗口中这是需要更新的文本框。

<input type="text" id="txtBoxDisplay" value=""/> 

在父窗口中创建一个函数的新文字

<script> 
.... 
.... 
.... 
function updateTextBox(theTextString) 
{ 
    $("#txtBoxDisplay").val(theTextString); //assuming you are using jquery 
    document.getElementById('txtBoxDisplay').value = theTextString; // if not using jquery 
} 
</script> 

在子页/模态窗口中使用下面的代码来访问父JSP的功能

window.opener.updateTextBox("Display this text in the parent text box"); 
更新textbod

您也可以使用

parent.updateTextBox("Display this text in the parent text box"); 

欲了解更多详情,请参阅以下链接

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

0

如果你没有提交任何表单,那么服务器显然不知道你在模态窗口中做出的选择。

使用JavaScript初始化父窗口中的文本字段与选定的收音机。因为我觉得你使用JQuery来打开对话框,所以你不应该在模态对话框中调用在父窗口中定义的JavaScript函数。

相关问题