I have a small problem that I would like some ideas to solve:
I have a request screen, where I select the product in a combo, I inform the quantity and when I click on a button, I want to insert the data of the value of the combo and the value of the quantity in some javascript array, display in a table just below and insert this data into a php array for when to save the request, be able to scan this array in php and save the data in the database.
Is there a way to make it simple?
Complementing the question:
I currently use the jQuery libraries and my system is done in CodeIgniter. The Array in PHP I would keep in the same view and would pass as parameter to the Controller when I would save everything in the bank.
I currently use an Ajax to fetch the price of the bank product without giving the refresh, so the part of fetching bank data with ajax I can already turn around, as I show below:
<script type="text/javascript">
$(document).ready(function () {
$("select[name='produto_id']").change(function () {
var base_url = '<?php echo base_url();?>';
alert('Entrou');
var preco = $("input[name='valor']");
//var teste = $("select[name='nome']").val();
//alert(teste);
$(preco).val('Carregando...');
$.ajax({
type: "POST",
//url: "application/views/admin/teste.php",
url: '<?php echo base_url(); ?>index.php?admin/list_dropdown',
data: "prod=" + $("select[name='produto_id']").val(),
success: function (json) {
alert(json);
//$(preco).val((Math.round(json * 100) / 100)).toFixed(2);
$(preco).val(json).toFixed(2);
}
});
//);
});
});
</script>
My question, would be, how to get this data from javascript, add it to an array in PHP (because I do not know how many products will be selected) then, when I click the save button, I send this array together to the controller .
A hug!