Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [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
buliq
post
Post #2





Grupa: Zarejestrowani
Postów: 559
Pomógł: 93
Dołączył: 4.03.2008
Skąd: Olsztyn

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


form class check, name check, button id check, class check

Ile tych check będziesz używał?

nadajesz im klasę "sprawdzam" następnie dla

Kod
$(".sprawdzam").click(function(){
ktory = $(this).attr('name');
});


--------------------
KTOŚ TU PACZY???

Kompedium wiedzy
Go to the top of the page
+Quote Post

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: 19.08.2025 - 11:04