<table width="99%"  height="540px">
  <tr>
    <td  width="99%" align="left" valign="top"  style="border:1px solid #B4C9C6;height:180px;width:750px;background-color: #fff;">
<div style=" overflow:auto;height:100%;">
<s:form id="searchForm" target="myframe" action="searchSelectedQuestion" namespace="/data" onsubmit="return checkInput();">
<input type="submit" value="搜索" name="advencesearch" id="search-submit" style="margin-top: 10px"/>

<table  class="t2"  id="showQuestion">

</table>
</s:form>
</div>
</td>
  </tr>
  <tr>
    <td style="border:1px solid #B4C9C6;height:340px;background-color: #fff;">
     <iframe onload="initPage()" width="100%" height="100%" frameborder="0" id="myframe" name="myframe" scrolling="auto">
    
     </iframe>
    </td>
  </tr>
</table>

解决方案 »

  1.   

    我想在myframe中,调用到父窗口的searchForm表单,怎么实现  急急急!!!
      

  2.   

    parent.document.searchForm....
    这样操作试过吗?
      

  3.   

    首先楼主要把form表单里面的s标签删除,不然js不能识别该标签的,s应该是jsp里面的标签吧,以下是我写的方法,分别用js和jquery实现,希望对楼主有所帮助。
    1、你先删除s标签,修改为<form id="searchForm" target="myframe" action="searchSelectedQuestion" namespace="/data" onsubmit="return checkInput();">
                                                <input type="submit" value="搜索" name="advencesearch" id="search-submit" style="margin-top: 10px"/>
                                                
                                                <table  class="t2"  id="showQuestion">
                                                    
                                                </table>
                                            </form>2、假设iframe里面的内容为:<!DOCTYPE html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>test</title>
        <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
        <style type="text/css">
        </style>
        <script type="text/javascript">
            //js直接实现
            function testFunc(){
                //获取父窗口的表单ID
                var form = window.parent.document.getElementById("searchForm");
                //form.属性名  //获取form的属性
                //提交表单
                form.submit();
            }
            //jQuery方法实现
            $(function(){
                $('#test').click(function(){
                    var form = $('#searchForm',parent.document);
                    //jquery对象转换为js对象
                    form.get(0).submit();
                });
            })
        </script>
    </head>
    <body>
        <input type="button" value="test" id="test" onclick="testFunc();">
    </body>
    </html>这样当你点击按钮的时候,上面的表单就会提交了
      

  4.   

    另外附上父窗口与iframe子窗口之间传值的方法,希望对楼主有所帮助。在父窗口中获取iframe中的元素
    1、js代码(1)第一种方法
    格式:window.frames["iframe的name值"].document.getElementById("iframe中控件的ID").click();
    //window.frames["mainIframe"].document.getElementById("iTextValue").value;
    //触发iframe中的元素的单击事件
    //window.frames["mainIframe"].document.getElementById("iTestClick").click();(2)第二种方法
    格式:
    var obj=document.getElementById("iframe的ID").contentWindow;
    var ifmObj=obj.document.getElementById("iframe中控件的ID");
    ifmObj.click();
    //var obj=document.getElementById("mainIframe").contentWindow;
    //var ifmObj=obj.document.getElementById("iTestClick");
    //ifmObj.click();2、jquery代码(1)第一种方法
    格式:$("#iframe的ID").contents().find("#iframe中的控件ID").click();
    //$("#mainIframe").contents().find("#iTextValue").val();(2)第二种方法
    格式:$("#iframe中的控件ID", window.frames("frame的name").document).click();
    //$("#iTextValue",window.frames["mainIframe"].document).val();在iframe中获取父窗口的元素
    1、js代码格式:window.parent.document.getElementById("父窗口的元素ID").click();
    //window.parent.document.getElementById("testClick").click();2、jquery代码格式:$('#父窗口中的元素ID', parent.document).click();
    //$('#textValue', parent.document).val();
      

  5.   

    window.parent.document.getElementById("searchForm表单中某元素的ID");这样就可以了
      

  6.   

    window.parent 父窗口
    top 顶层窗口
      

  7.   

    能不能不改s标签的情况下得到这个form表单。
    因为这个s标签,其它地方有用到,改了就影响到其它功能了。
      

  8.   

    鉴于刚才测试,纠正一下3楼的错误。
    jsp标签最终会转化为HTML标签,js可以对jsp标签进行操作。