I have a page where customers can enter the number of products they would like to order. Therefore I made use of the jquery key-up function in combination with an ajax script:
<input type="text" class="number" data-product_id="1">
<input type="text" class="number" data-product_id="2">
<input type="text" class="number" data-product_id="3">
etc.
<script>
$(function() {
$("input.number").keyup(function() {
$.post("number.php", { product_id: $(this).data('product_id'), number: $(this).val() }, function(data){ if (data != "1") { alert('Error occurred'); } });
});
})
</script>
Basically, this system is working well. The numbers are temporary stored via a PHP Session and will be processed later. But there is a problem: there are multiple input fields (> 500) and users enters the number of items they would like to order really fast with the tab-button. I found out that not all the numbers are stored correctly if the users enters it really fast despite the fact that te number.php file is really small in size, just the row $_SESSION[$_POST['product_id']] = $_POST['number'];
is in the file.
Are there any solutions for checking of all the fields are submitted?