Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z wysyłaniem formularza, XMLHttpRequest()
marrrecki
post
Post #1





Grupa: Zarejestrowani
Postów: 110
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Lublin

Ostrzeżenie: (0%)
-----


Witam. Mam zrobiona stronkę z cenami produktów i chciałem zrobić przeliczanie cen netto i brutto poprzez javascript. I pojawił mi sie problem. Ponieważ w formularzu mam wiele pól input o bardzo podobnych nazwach, gdzieś w javascripcie xle mi wszystko widzi.
Tak wyglada mój js:

  1. function doRound(x, places) {
  2. return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
  3. }
  4.  
  5. function getTaxRate(i) {
  6. return 22;
  7. }
  8.  
  9. function updateGross(i) {
  10. var taxRate = getTaxRate(i);
  11. var grossValue = document.forms["product_list"].cena_+i.value;
  12.  
  13. if (taxRate > 0) {
  14. grossValue = grossValue * ((taxRate / 100) + 1);
  15. }
  16.  
  17. document.forms["product_list"].cena_brutto_+i.value = doRound(grossValue, 4);
  18. }


a tak fragment formularza:

  1. <tr>
  2.  
  3. <td class=ordcont><input type="checkbox" name="selected[0]"></td>
  4. <td class=ordcont>AGDAMILOZ0001</td>
  5. <td class=ordcont>Chłodziarko-zamrażarka AMICA ACZ 3802 ZP</td>
  6. <td class=ordcont><input type="text" name="cena_0" value="1313.6700" onKeyUp="updateGross(0)"></td>
  7. <td class=ordcont><input type="text" name="cena_brutto_0" value="1313.6700" OnKeyUp="updateNet(0)"></td>
  8. <td class=ordcont><input type="text" name="marza_0" value="8.0" size="2" onKeyUp="updateGross(0); updateNet(0);">%</td>
  9. <td class=ordcont><input type="text" name="products_quantity[0]" value="1" size="2"></td>
  10.  
  11. <td class=ordcont>Amica</td>
  12. <td class=ordcont> </td>
  13. </tr>
  14. <script language="javascript"><!--
  15. updateGross(0);
  16. //--></script>
  17.  
  18. <tr>
  19. <td class=ordcont><input type="checkbox" name="selected[1]"></td>
  20. <td class=ordcont>AGDAMILOZ0002</td>
  21.  
  22. <td class=ordcont>Chłodziarko-zamrażarka AMICA ACZ 3702 ZP</td>
  23. <td class=ordcont><input type="text" name="cena_1" value="1182.3300" onKeyUp="updateGross(1)"></td>
  24. <td class=ordcont><input type="text" name="cena_brutto_1" value="1182.3300" OnKeyUp="updateNet(1)"></td>
  25. <td class=ordcont><input type="text" name="marza_1" value="8.0" size="2" onKeyUp="updateGross(1); updateNet(1);">%</td>
  26. <td class=ordcont><input type="text" name="products_quantity[1]" value="1" size="2"></td>
  27. <td class=ordcont>Amica</td>
  28. <td class=ordcont> </td>
  29.  
  30. </tr>
  31. <script language="javascript"><!--
  32. updateGross(1);
  33. //--></script>
  34.  
  35. <tr>
  36. <td class=ordcont><input type="checkbox" name="selected[2]"></td>
  37. <td class=ordcont>AGDAMILOZ0003</td>
  38. <td class=ordcont>Chłodziarko-zamrażarka AMICA ACZ 3602 ZP</td>
  39. <td class=ordcont><input type="text" name="cena_2" value="1084.6700" onKeyUp="updateGross(2)"></td>
  40.  
  41. <td class=ordcont><input type="text" name="cena_brutto_2" value="1084.6700" OnKeyUp="updateNet(2)"></td>
  42. <td class=ordcont><input type="text" name="marza_2" value="8.0" size="2" onKeyUp="updateGross(2); updateNet(2);">%</td>
  43. <td class=ordcont><input type="text" name="products_quantity[2]" value="1" size="2"></td>
  44. <td class=ordcont>Amica</td>
  45. <td class=ordcont> </td>
  46. </tr>
  47. <script language="javascript"><!--
  48. updateGross(2);
  49. //--></script>



Gdzie jest błąd? Czy ktos może mi pomóc?

Ten post edytował marrrecki 29.10.2007, 20:41:27
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 01:29