6
I really need some help..
I have a select with the products:
<!-- panel preview -->
<div class="col-sm-5">
<h4>Adicionar Produtos:</h4>
<div class="panel panel-default">
<div class="panel-body form-horizontal payment-form">
<div class="form-group">
<label for="status" class="col-sm-3 control-label">Escolha o produto</label>
<div class="col-sm-9">
<select id="status" name="status[]" class="order-type">
<option value="cake">Tortas Confeitadas</option>
<option value="lollipop">Bolos Caseiros</option>
<option value="dessert">Pão</option>
</select>
</div>
</div>
<div class="form-group">
<label for="amount" class="col-sm-3 control-label">Quantidade</label>
<div class="col-sm-9">
<input type="number" class="form-control" id="amount" name="amount[]" required="required">
</div>
</div>
<div class="form-group">
<div class="col-sm-12 text-right">
<button type="button" class="btn btn-default preview-add-button">
<span class="ico-plus"></span> Add
</button>
</div>
</div>
</div>
</div>
</div> <!-- / panel preview -->
By clicking the Add button Avascript shows a "preview" of the selected products in the table below.
<div class="col-sm-7">
<h4>Preview:</h4>
<div class="row">
<div class="col-xs-6">
<div class="table-responsive">
<table class="table preview-table" id="example-table">
<thead>
<tr>
<th>Produto</th>
<th>Quantidade</th>
</tr>
</thead>
<tbody></tbody> <!-- preview content goes here-->
</table>
</div>
</div>
</div>
<div class="row text-left">
<div class="col-xs-4">
<h4>Total: <strong class="preview-total"></strong></h4>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<hr style="border:1px dashed #dddddd;">
<button class="btn-block convert-table">Enviar pedido</button>
</div>
</div>
</div>
The Java responsible for doing this, is the following:
$('.preview-add-button').click(function(){
var form_data = {};
form_data["status"] = $('.payment-form #status option:selected').text();
form_data["amount"] = parseFloat($('.payment-form input[name="amount[]"]').val()).toFixed(2);
form_data["remove-row"] = '<span class="ico-cancel"></span>';
var row = $('<tr></tr>');
$.each(form_data, function( type, value ) {
$('<td class="input-'+type+'"></td>').html(value).appendTo(row);
});
$('.preview-table > tbody:last').append(row);
calc_total();
});
What I need, is to take the data of this "preview" and send to another view, I know I have to send in JSON, but as this data goes to another page, I believe that can not be in ajax, I’m sure?
Can someone help me send this data to PHP?
Thank you very much.
Please avoid long discussions in the comments; your talk was moved to the chat
– Maniero