将div设置为一个post方法的结果页面的目标容器 [英] set div as target container for result page of a post method

查看:637
本文介绍了将div设置为一个post方法的结果页面的目标容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

。我有一个div标签,也被分成两个div。这里是代码:

 < div> 
< div id =search>
< form id =trymethod =post>
Batch:< input id =batchname =batchtype =text/> Dept:< input id =deptname =depttype =text><<< ; input type =submit/>
< / div>
< div id =receiver>

< / div>
< / div>

我使用post方法在名为search的div中放置了一个搜索选项。我想要做的是,当我点击提交按钮页面接收值将出现在名为接收器的div。



这可能吗?如果是的话,请帮助..

解决方案

您有这方面的方式:
$

 < div id = 1  - 最简单的 - 而不是div  - 使用这样的IFrame 

搜索 >
< form id =trymethod =posttarget =receiveraction =url-to-server-Page>
批次:< input id =batchname =batchtype =text/>
部门:< input id =deptname =depttype =text/>
< input type =submit/>
< / form>
< / div>
< iframe name =receiverid =receiver>< / iframe>
< / div>

在这种情况下,缺点是搜索结果来自 url -to-server-page - 是嵌套在搜索页面中的完整且独立的HTML页面。
它不受父页面样式的影响,并且它们之间的JavaScript操作通信相当复杂。

2 - 具有一些JavaScript技能,您可以使用AJAX。
网上有很多库,可以帮你用很少的几行代码来完成它。
jQuery是最简单的,尽管它是我最喜欢的一个...
http://jquery.com /



<3> - 使用完整往返

 < div id =search> 
< form id =trymethod =posttarget =receiveraction =url-to-server-Page>
批次:< input id =batchname =batchtype =text/>
部门:< input id =deptname =depttype =text/>
< input type =submit/>
< / form>
< div id =receiver>
<?php if(isset($ _ POST ['batch'])&& isset($ _ POST ['dept'])){
//在这里显示搜索结果。
}
?>
< / div>
< / div>


.I have a div tag that is also divided into two divs. here is the code:

<div>
<div id="search">
<form id="try" method="post">
Batch: <input id="batch" name="batch" type="text"/>Dept: <input id="dept" name="dept" type="text"><input type="submit"/>
</div>
<div id="receiver">

</div>
</div>

I have placed a search option in the div named "search" using post method. what i want to do is that when i click the submit button the page to receive the values will appear on the div named "receiver".

is this possible? if it is, please help..

解决方案

The ways you have for this are:

1 - The simplest - instead of a div - use an IFrame like this

<div id="search">
  <form id="try" method="post" target="receiver" action="url-to-server-Page">
     Batch: <input id="batch" name="batch" type="text"/>
     Dept: <input id="dept" name="dept" type="text" />    
     <input type="submit"/>
  </form>
  </div>
  <iframe name="receiver" id="receiver"></iframe>
</div>

The disadvantage in this case is that the search-result that come in this case from url-to-server-page - is a complete and independent HTML page that is nested in your search page. It is not effected by styles of the parent page, and the communication between them for JavaScript operations is rather combersome.

2 - with some JavaScript skills you can use AJAX. There are many libraries on the net that can help you do it in very few lines of code. jQuery is the simplest, although it's the one I like least... http://jquery.com/

3 - use a full round-trip

  <div id="search">
    <form id="try" method="post" target="receiver" action="url-to-server-Page">
       Batch: <input id="batch" name="batch" type="text"/>
       Dept: <input id="dept" name="dept" type="text" />    
      <input type="submit"/>
    </form>
    <div id="receiver">
        <?php if (isset($_POST['batch']) && isset($_POST['dept'])){
                  //display search results here.
              }
        ?>
    </div>
 </div>

这篇关于将div设置为一个post方法的结果页面的目标容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆