Problem jest taki, że jak daje na samym końcu funkcji submitchecker
alert('TICK to: ' + ajax_checker(parseInt(document.cart.quantity.value), document.cart.code0.value, document.cart.code1.value, document.cart.code2.value, document.cart.code3.value, document.cart.code4.value));
to dostaje cały czas undefined

[JAVASCRIPT] pobierz, plaintext
  1. function ajax_checker(quantity_value, code0, code1, code2, code3, code4) {
  2.  
  3. $.post("js/ajax_checker.php",{checker:quantity_value, code0:code0, code1:code1, code2:code2, code3:code3, code4:code4}, function(data) {
  4. if (data) return false;
  5. else return true;
  6. });
  7. }
  8.  
  9.  
  10. function submitchecker()
  11. {
  12. //wartości przesyłane do funkcji są poprawne, sprawdzane alertem
  13. if (ajax_checker(parseInt(document.cart.quantity.value), document.cart.code0.value, document.cart.code1.value, document.cart.code2.value, document.cart.code3.value, document.cart.code4.value)) document.cart.submit();
  14. else alert("Pola wymagane musza być zaznaczone i miec poprawna wartosc!");
  15. }
[JAVASCRIPT] pobierz, plaintext


Na formularzu jest:
  1. [/php]
  2.  
  3.  
  4. //ten plik jest raczej ok bo jak go wywołuję ręcznie z parametrami to zwraca poprawne wartości, czyli wyświetla nic lub coś w przypadku błędnych danych
  5. [php]
  6. $marker = FALSE;
  7. //database connection
  8.  
  9.  
  10. //code check
  11. $checker = trim($_REQUEST['checker']); //wartośc pola quantity
  12. $code0 = trim($_REQUEST['code0']);
  13. $code1 = trim($_REQUEST['code1']);
  14. $code2 = trim($_REQUEST['code2']);
  15. $code3 = trim($_REQUEST['code3']);
  16. $code4 = trim($_REQUEST['code4']);
  17.  
  18.  
  19.  
  20. //quantity check
  21. for ($i=0; $i<5; $i++) {
  22. $code = trim($_REQUEST['code'.$i]);
  23. $countable += mysql_num_rows(mysql_query("SELECT id FROM grupon WHERE product_id=4 AND checker=0 AND code= BINARY '$code'"));
  24. }
  25.  
  26.  
  27.  
  28. $grupon_counter = mysql_num_rows(mysql_query("SELECT id FROM grupon WHERE checker=0 AND code=BINARY '$code0' OR code=BINARY '$code1' OR code=BINARY'$code2' OR code=BINARY'$code3' OR code=BINARY'$code4'"));
  29.  
  30. if ($grupon_counter && $checker == $countable) $marker = TRUE; //check if the useful code is in DB
  31. if ($marker) {} //if it is print nothing
  32. else echo 'Kod ' .$checker. ' jest niepoprawny lub został już użyty'; //it it isnt print error massege
  33.  
  34.  


Plik z formularzem
  1. <img id="submit_button" onClick="submitchecker();" src="layout/1/cart_order_off.png">