Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX] Wykrycie przycisku submit
Emkacf
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 5.09.2013

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


Hej,
Mam formularz z trzema przyciskami i chciałabym przez jquery wykrywać który z nich został wciśnięty i dodawać tą informację do danych przesyłanych przez ajax

  1. <form class="check" name="checkf" action="check.php" method="POST">
  2. <input name="code" type="text" value=""/>
  3. <button type="submit" name="return" value="" class="return">zwrócona</button>
  4. <button type="submit" name="given" value="" class="given">wydana</button>
  5. <button id="check" type="submit" name="check" value="" class="check">Sprawdź kod<img style="position:relative;top:3px;padding-left:7px;" src="./assets/img/loupe.png" alt='lupa'/></button>
  6. </form>


  1. $('.check').submit(function() {
  2. alert($(this).serialize()); // check to show that all form data is being submitted
  3. $.post("check.php",$(this).serialize(),function(data){
  4. alert(data); //check to show that the calculation was successful
  5. });
  6. return false; // return false to stop the page submitting. You could have the form action set to the same PHP page so if people dont have JS on they can still use the form
  7. });
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: 22.08.2025 - 18:47