【问题标题】:how to pass radiobutton value from one jsp to another jsp如何将单选按钮值从一个jsp传递到另一个jsp
【发布时间】:2011-07-21 07:53:54
【问题描述】:

我有一个 jsp 页面,上面有一个图像,单击该图像时,我打开一个模式窗口,其中包含具有相应值的单选按钮(另一个 jsp)...

我想要实现的是选择单选按钮,将其值分配给父页面上的文本框...

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

我试图用 session 来做,但不知道确切的方法......

任何建议或意见都将受到高度评价。 谢谢

【问题讨论】:

    标签: javascript jquery jsp session modal-dialog


    【解决方案1】:

    如果您没有提交任何表单,那么服务器显然对您在模式窗口中所做的选择一无所知。

    使用 JavaScript 来初始化父窗口中带有所选单选的文本字段。既然我猜你正在使用 JQuery 打开对话框,那么从模态对话框调用父窗口中定义的 JavaScript 函数应该没有任何问题。

    【讨论】:

      【解决方案2】:

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

      <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");
      

      你也可以使用

      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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-02
        相关资源
        最近更新 更多