Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] Tylko jedno pole może być wypełnione
@rtur
post
Post #1





Grupa: Zarejestrowani
Postów: 254
Pomógł: 3
Dołączył: 23.02.2006

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


  1. $(function() {
  2.  
  3. $('#band').autocomplete({
  4. source: 'ajax-band.php',
  5. minLength: 2,
  6. select: function(event, ui) {
  7. $('#bandID').val(ui.item.id);
  8. $('#band').val(ui.item.band);
  9. }
  10. });
  11. $('#people').autocomplete({
  12. source: 'ajax-people.php',
  13. minLength: 2,
  14. select: function(event, ui) {
  15. $('#peopleID').val(ui.item.id);
  16. $('#people').val(ui.item.people);
  17. }
  18. });
  19. });
  20.  
  21. <form action='index.php' method='post'>
  22. <label for='band'>Zespół</label>
  23. <input type='text' id='band' name='band' /><br />
  24. <label for='band'>Artysta</label>
  25. <input type='text' id='people' name='people' /><br />
  26. <input type='hidden' id='bandID' name='bandID' />
  27. <input type='hidden' id='peopleID' name='peopleID' />
  28. <p><input type='submit' name='submitBtn' value='Dodaj' /></p>
  29. </form>

Mam formularz który może mieć wypełnione tylko jedno pole, albo Artysta albo Zespół w zależności od tego co wpiszę w te pola wypełniają się odpowiednimi wartościami ID pola input type hidden. Co zrobić aby można było wypełnić tylko jedno pole (Artysta albo Zespół), jak zostaną wypełnione oba to pojawi się komunikat?


--------------------
Artur
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 20.08.2025 - 19:05