Set div as target container for post method results page

. I have a div tag that is also split 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 placed the search option in a div called "search" using the post method. what I want to do is that when I click the submit button, the page, in order to get the values, will appear in a div called "receiver".

Is it possible? if there is, please help ..

+3
source share
3 answers

You have the following ways:

1 - The simplest - instead of div - use an IFrame similar to 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>

, , url-to-server-page, - HTML-, . , JavaScript .

2 - JavaScript AJAX.   , .  jQuery - , ...  http://jquery.com/

3 -

  <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>
+4

, AJAX. , Google Web Toolkit jQuery, , .

0

Can you clarify? This is a php page and you send the message yourself or do you want to use ajax to populate the div?

If it is php and you send the message yourself, you can simply check if the message was made inside this div:

<div id="receiver">
    <?php if (isset($_POST['batch']) && isset($_POST['dept'])){
              //display search results here.
          }
    ?>
</div>
0
source

All Articles