Updating session array with jquery
I have dynamicaly created table with products:
detail qty price total
detail1 3 23 69
detail2 1 3 3
Qty is in text input field. 开发者_C百科every qty text field name is unique detail code. I need that every time i change qty field, it updates session array with that unigue detail code.
How can i do this over jquery without submitting form?Sorry for my bad english, omerimuni
This code has been taken (and modified slightly) from another answer - but it should solve your problem. Try this -
$('input:text[id*="qty"]').bind('keyup',function() {
$.post("my_other_script.php", { qty: this.id} );
});
'my_other_script.php' would then be -
<?php $_SESSION['qty'] = $_POST['qty']; ?>
You should use jQuery's ajax and focusout
http://api.jquery.com/focusout/
http://api.jquery.com/jQuery.ajax/
User changes qty. Upon leaving that textbox, send ajax request to update your session variable.
Create a server side service with your prefered Server side techno. This service will take your request and put the value you passed in your http Session.
Then use the Ajax module of JQuery to post you request to the service you just created.
精彩评论