Witam,
Chciałbym, żeby po kliknięciu w przycisk ZAMÓW, otworzył się (ukryty) formularz, a w temacie formularza automatycznie pojawiły się (wygenerowane) dane - pola $nazwa $nr_katalogowy, a po kliknięciu w przycisk WYŚLIJ formularza lub poza nim, ten zniknął/
<?php http://www.php.net/echo "<div id=\"container\"> <ul class=\"list\"> <li> <section class=\"list-top\"> <h5 class=\"title\"> <span class=\"temat\">$nazwa $nr_katalogowy</span> </h5> <span class=\"priceH\">Cena brutto: <b>$c_brutto</b> zł</span> <span class=\"tech\"> <b>Numer katalogowy:</b> $nr_katalogowy <br/> </span> </section> <section class=\"list-right\"> <span><a class=\"zamow\">ZAMÓW</a></span> </section> <div class=\"clearfix\"></div> </li> </ul> </div>"; ?>
<http://december.com/html/4/element/div.html id="zamow" style="display:none" > <section id="formularz"> <http://december.com/html/4/element/div.html class="form-container"> <http://december.com/html/4/element/div.html class="col-md-12"> <http://december.com/html/4/element/form.html id="main-contact-form" class="formularz" name="formularz" method="post" action="sendemail.php"> <http://december.com/html/4/element/input.html type="text" class="form-control" id="title" name="title" required="required" placeholder="Temat *" value="<?php echo $formtyt; ?>"> <http://december.com/html/4/element/input.html type="text" class="form-control" id="name" name="name" required="required" placeholder="Imię *"> <http://december.com/html/4/element/input.html type="text" class="form-control" id="number" name="number" placeholder="Telefon"> <http://december.com/html/4/element/input.html type="email" class="form-control" id="email" name="email" required="required" placeholder="Adres e-mail *"> <http://december.com/html/4/element/textarea.html class="form-control" rows="3" id="message" name="message" required="required" placeholder="Wiadomość *"></http://december.com/html/4/element/textarea.html> <http://december.com/html/4/element/button.html class="btn btn-default" id="submit" type="submit" name="submit" >WYŚLIJ</http://december.com/html/4/element/button.html> <http://december.com/html/4/element/button.html class="btn btn-default" id="reset" type="reset" name="reset" >Wyczyść</http://december.com/html/4/element/button.html> </http://december.com/html/4/element/form.html> </http://december.com/html/4/element/div.html> </http://december.com/html/4/element/div.html> </section> </http://december.com/html/4/element/div.html>
Pytanie, ktore w tym miesiacu byla zadane petryliard razy: co znaczy/czym sie objawia to "NIE DZIALA" ?
Przepraszam za brak precyzji.
Niestety nie działa już sam początek, czyli brak reakcji na kliknięcie w ZAMÓW.
Miałem wcześniej działającą akcję, ale to chyba nie było właściwe rozwiązanie:
Wstaw console.log(jakas zmienna np event); i zobacz co się dzieje, czy się wykonuje kod.
Consola niestety niczego nie pokazuje
Jeśli kompletnie niczego nie pokazuje chociaż masz to zdarzenie podpięte to znaczy że zły element podałeś.
Szczerze mówiąc, to nie jestem pewien, czy w ogóle mam poprawnie napisanego ajaxa i poprawne odwołanie
No nie bardzo.
$('#container').on('click', '.zamow', function(){})
https://prophp.pl/article/28/propagacja_i_delegacja_zdarzen_w_javascript
To chyba też nie to. Wciąż brak info w consoli.
https://jsfiddle.net/b612ntr7/
W jsfiddle'u pokazuje mi taką samą zawartość consoli jak u mnie.
https://ibb.co/i3iefR
Bo tu dodałem czerwony kolor po kliknięciu.
Tak, wiem.
Podmieniłem kod, do celów testowych, na ten Twój:
W takim razie czegoś tu nie mówisz np nie osadziles jquery albo coś jest inaczej generowane.
Raczej wszystko jest OK, ponieważ np. poniższy kod
Jedno nie ma nic wspólnego z drugim (js wykonuje się dawno jak php przestaje działać) chyba że masz taki śmietnik w strukturze dom że nic nie jest poprawnie pozamykane.
Witam,
W jaki sposób zmodyfikować hide('zamow'); żeby zadziałało dopiero po komunikacie o wysłaniu wiadomości "text-success"?
$('#zamow').delay(3000).hide(0);
Pięknie dziękuję. Działa jak trzeba. :-)
Wracając do formularza
<http://december.com/html/4/element/div.html id="zamow" style="display:none" > <section id="formularz"> <http://december.com/html/4/element/div.html class="form-container"> <http://december.com/html/4/element/div.html class="col-md-12"> <http://december.com/html/4/element/form.html id="main-contact-form" class="formularz" name="formularz" method="post" action="sendemail.php"> <http://december.com/html/4/element/span.html class="close">x</http://december.com/html/4/element/span.html> <http://december.com/html/4/element/input.html type="text" class="form-control" id="title" name="title" required="required" placeholder="Temat *"> <http://december.com/html/4/element/input.html type="text" class="form-control" id="name" name="name" required="required" placeholder="Imię *"> <http://december.com/html/4/element/input.html type="text" class="form-control" id="number" name="number" placeholder="Telefon"> <http://december.com/html/4/element/input.html type="email" class="form-control" id="email" name="email" required="required" placeholder="Adres e-mail *"> <http://december.com/html/4/element/textarea.html class="form-control" rows="3" id="message" name="message" required="required" placeholder="Wiadomość *"></http://december.com/html/4/element/textarea.html> <http://december.com/html/4/element/button.html class="btn btn-default" id="submit" type="submit" name="submit" >WYŚLIJ</http://december.com/html/4/element/button.html> <http://december.com/html/4/element/button.html class="btn btn-default" id="reset" type="reset" name="reset" >Wyczyść</http://december.com/html/4/element/button.html> </http://december.com/html/4/element/form.html> </http://december.com/html/4/element/div.html> </http://december.com/html/4/element/div.html> </section> </http://december.com/html/4/element/div.html>
$(document).ready(function() { var form = $('#main-contact-form'); form.on('submit', function(event){ event.preventDefault(); var form_status = $('<div class="form_status"></div>'); $.ajax({ url: $(this).attr('action'), method: 'POST', data: form.serialize(), beforeSend: function() { form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Wysyłanie wiadomości ...</p>').fadeIn() ); } }).done(function(data){ form_status.html('<p class="text-success">' + data.message + '</p>').delay(3000).fadeOut(); // hide('zamow'); $('#zamow').delay(3000).hide(0); }); }); $('#display').on('click', '.product .zamow', function(event) { event.preventDefault(); var formtyt = $(this).parents('li').find('.list-top span.temat').html(); $('#main-contact-form > #title').val(formtyt); show('zamow'); }); $('#zamow').on('click', '.close', function(event) { event.preventDefault(); hide('zamow'); }); });
$('#display').on('click', '.product .zamow', function(event) { event.preventDefault(); var formtyt = $(this).parents('li').find('.list-top span.temat').html(); $('#main-contact-form > #title').val(formtyt); show('zamow'); });
var formtyt = $(this).parents('li').find('.list-top span.temat').text();
Ależ to było proste. :-o Wielkie dzięki. :-)
Kombinowałem z tym text na różne sposoby, ale chyba tego nie sprawdziłem.
@trueblue można się z Tobą jakoś skontaktować na priv?
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)