Saturday, 17 August 2013

Appending and substracting divs filled with data from one simple form to a form that contains all the divs grouped and ready to POST

Appending and substracting divs filled with data from one simple form to a
form that contains all the divs grouped and ready to POST

So this is the deal:
I have an order page and I use two forms.
The first form contains input data for ONE order item and when I press OK
I will pass the form's input data to javascript through
onsubmit=send_item_data(this) and at the end i will return false; in
send_item_data function so it doesn't get posted.
In the second one I want to append/substract the former data in div groups
(so I can add more or delete them easily) but I can't think (or find) of a
solution that puts in group the data from the first form in one div and
appends that child div to the second form.
In the end, by the push of a button, the second form will post all the
divs' data and I will handle it with PHP backend code.
Code body:
<form action="" id="first_form" method="post" onsubmit="return
send_item_data(this)">
<div id="Select_list">
<select blah blah>
---bunch of options---
</select>
</div>
<div id="extras">
---Some extras that you can choose by a checkbox input (I
generate it via PHP)---
example:
<input name="checkbox[<?php echo
$row['column_data_from_query']?>]" type="checkbox"
value="checked">
</div>
--->Possibly two more input fields here<---
<input type="button" value="clear" onclick="clear_form()">
<input type="submit" value="OK">
</form>
<form action="" id="finalize_order_form" method="post">
--->This is the second form<---
--->In here I want to put the data from the first form so i can handle
them by group<---
if I click OK three times in the first form there should be three
groups here that contain each form's data
<input type="submit" class="button" value="Finallize order"/>
</form>
I mainly use PHP Mysql and Javascript (including AJAX, not jQuery).

No comments:

Post a Comment