Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 15th, 2012  |  syntax: None  |  size: 0.79 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Passing value along with MySQL retrieved value as hidden value in JavaScript to AJAX function
  2. <select name="update" onchange="updatequantity(this.value,<?php echo $row['products_id']; ?>)" >
  3.        
  4. <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js"></script>
  5. <script type="text/javascript">
  6. function updatequantity(input, id)
  7.     dojo.xhrPost({
  8.             url: "updatequantity.php",
  9.             content: {
  10.                   id: id,
  11.                   quantity: input.value
  12.             },
  13.             load: function(result) {
  14.                   result //this variable will hold the quantity
  15.             }
  16.     });
  17. </script>
  18.        
  19. <?php
  20. $id = $_POST['id'];
  21. $quantity = $_POST['quantity'];
  22. //some sql query like "update cart_items set quantity=".$quantity." where id=".$id.";"
  23. echo $quantity;