Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> odwołanie do elementów formularza input text
john_doe
post
Post #1





Grupa: Zarejestrowani
Postów: 873
Pomógł: 25
Dołączył: 24.07.2005

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


Witam

mam formularz
  1. <form action="edit.php" method="POST" id="editCartForm" onSubmit="ValidateForm();" >';
  2.  
  3.  
  4. while( $row = mysql_fetch_array( $result ) )
  5. {
  6. print '<tr>';
  7.  
  8. print '<td>' . $row[0] . '</td>';
  9. print '<td>' . $row[1] . '</td>';
  10. print '<td><input type="text" size="3" name="qty[' . $row[0] . ']" value="'.$_SESSION['koszyk'][$row[0]].'" style="text-align: center;" /></td>';
  11. print '<td>' . $row[3] . '</td>';
  12. print '<td>' . $_SESSION['koszyk'][$row[0]] * $row[3] . '.</td>';
  13.  
  14. print '</tr>';
  15. }
  16. print '<tr>
  17. <td align="center" colspan="6">
  18. <input type="submit" name="submit" value="Zmien" />
  19. <input type="button" value="Rezygnuj" onClick="document.location.href=\'add.php?action=view\'" />
  20. </td>
  21. </tr>';
  22.  
  23. print '</table></form>';


chcę go przed wysłaniem walidować pod względem czy wpisano liczbę całkowitą
  1. [/php]
  2. document.forms['editCartForm'].elements['qty[]'].length


dostaję
Błąd: document.forms.editCartForm.elements['qty[]'] is undefined
Plik źródłowy: http://127.0.0.1/Jukon/offers/editForm.php
Wiersz: 159

generalnie chce użyć petli for

  1. function integer_validate(src)
  2. {
  3. var regex = /^[\-]{0,1}[0-9]{1,8}$/;
  4. return regex.test(src);
  5. }
  6.  
  7. function ValidateForm()
  8. {
  9. var i;
  10.  
  11. //for ( i = 0 ; document.forms['editCartForm'].elements.length ; i++ )
  12. //{
  13. alert(document.forms['editCartForm'].elements['qty[]'].length);
  14. //}
  15.  
  16. //var inputValues = document.forms['editCartForm'].elements['qty[16]'].value;
  17.  
  18. //alert(inputValues);
  19.  
  20. //if(integer_validate(document.forms['editCartForm'].qtyy[i].value))
  21. // {
  22. // alert('ok');
  23. // }else {
  24. // alert ('zle zle zle');
  25. // }
  26.  
  27. }


pozdrawiam
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: 25.12.2025 - 07:08