Advertisement
Guest User

Untitled

a guest
May 5th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. <div class="product_stock" id="stock_form<?php echo $i; ?>"><?php
  2. $size = $product_sizes[0];
  3. $color = $product_colors[0];
  4. $sql = "SELECT * FROM products WHERE product_id = '$product_id' AND size = '$size' AND color = '$color'";
  5. $result = mysql_query($sql) or die(mysql_error());
  6. echo $sql;
  7.  
  8. if(mysql_num_rows($result) > 0) {
  9. $product_stock = mysql_fetch_array($result);
  10. if($product_stock['stock'] > 0) {
  11. echo "Nog ".$product_stock['stock']." verkrijgbaar";
  12. } else {
  13. echo "Combinatie is niet meer verkrijgbaar";
  14. }
  15. }?>
  16. </div>
  17. <div class="product_text">
  18. <?php echo $product['text']; ?>
  19. </div>
  20. <div class="product_num">
  21. art: #<?php echo $product['product_id']; ?>
  22. </div>
  23. <div class="product_bar_bot">
  24. <form name="form<?php echo $i; ?>" action="shopping_cart.php?">
  25. <input type="hidden" name="id" value="<?php echo $product['pid']; ?>"/>
  26. <select name="size" class="product_select" onChange="get_stock('form<?php echo $i; ?>');">
  27. <?php foreach($product_sizes as $p_size) { ?>
  28. <option>
  29. <?php echo $p_size; ?>
  30. </option>
  31. <?php } ?>
  32. </select>
  33. <select name="color" class="product_select" onChange="get_stock('form<?php echo $i; ?>');">
  34. <?php foreach($product_colors as $p_color) { ?>
  35. <option value="<?php echo $p_color; ?>">
  36. <?php echo $color_array[$p_color]; ?>
  37. </option>
  38. <?php } ?>
  39. </select>
  40. <input type="hidden" name="url" value="sale">
  41. <input type="hidden" name="action" value="add">
  42. <input type="text" name="amount" value="1" size="1" style="vertical-align: top; margin-top: 9px;"></input>
  43. <img src="images/icons/cart_shop.png" align="top"/>
  44. <input type="submit" class="button" value="Voeg toe" style="vertical-align: top; margin-top: 7px;">
  45.  
  46. function get_stock(formid) {
  47. var form = document.forms[formid];
  48. var size = form.size.value;
  49. var color = form.color.value;
  50. var pid = form.id.value;
  51. var stock = 'stock_'+formid;
  52.  
  53. // code for IE7+, Firefox, Chrome, Opera, Safari
  54. if (window.XMLHttpRequest) {
  55. xmlhttp=new XMLHttpRequest();
  56. } else {
  57. // code for IE6, IE5
  58. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  59. }
  60. xmlhttp.onreadystatechange=function() {
  61. if (xmlhttp.readyState==4 && xmlhttp.status==200) {
  62. document.getElementById(stock).innerHTML=xmlhttp.responseText;
  63. }
  64. }
  65. xmlhttp.open("GET","get_stock.php?id="+pid+"&size="+size+"&color="+color,true);
  66. xmlhttp.send();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement