hemiz
hemiz

Reputation: 91

Submitting form from different <div> HTML

i have problem with submitting a form using 2 defferent div(tabs). I want to submit all the value from this form.. but when i submit, the value that i receive only from (div class="tab1") not from div class="tab2". how can i submit all the value even using different div

page.php

<div class="tab1">
<h2>Basic Information</h2>
<form name="pages_details" method="post" action="pages/save_pages.php">
<table>  
    <tr>  
        <td>Name:</td>  
        <td><input name="name" type="text" ></input></td>  
    </tr>  
    <tr>  
        <td>Order:</td>  
        <td><input name="ord" type="text"></input></td>  
    </tr> 
</table>
</div>
<div class="tab2">
<h2>Additional Information</h2>
<table>  
 <tr>  
    <td>Special:</td>  
    <td><input name="special" type="text" ></input></td>  
 </tr> 
 <tr>  
    <td>Title:</td>  
    <td><input name="title" type="text"></input></td>  
 </tr> 
</table>
</div>
<input type="submit" name="save" value="save">
</form>

save_pages.php

<?php
$name = $_REQUEST['name'];
$ord = $_REQUEST['ord'];
$special = $_REQUEST['special'];
$title = $_REQUEST['title'];

echo $name;
echo $ord;
echo $special;
echo $title;
?>

Upvotes: 0

Views: 2356

Answers (2)

Eric T
Eric T

Reputation: 1026

I would suggest to use jquery ajax to submit the form based on your case.

For example:

var datas = $(form).serialize();
$.post("pages/save_pages.php", datas, function(){

});

Referring: post - http://api.jquery.com/jQuery.post/ serialize - http://api.jquery.com/serialize/

Upvotes: 1

gildra
gildra

Reputation: 46

Try to make sure you close tags in the right order. Structuring code like this can cause some weird bugs.

Not right:

<div>
<form>    
</div>
</form>

So you might want to do it like this.

<form>
<div>
</div>
</form>

Upvotes: 1

Related Questions