javascript - submit button doesn't disappear when submitted -
i have problem form on website. when hit submit button, button disappears user can't click twice on resulting in form submitted twice. have tried change function don't want give loading icon showing. can add function , add code to
onsubmit="showhide(); return true;"
? executes 2 functions? in advance!
<script src="https://www.google.com/recaptcha/api.js?hl=nl" async defer> </script> <script type="text/javascript"> function showhide() { var div = document.getelementbyid("hidden_div"); if (div.style.display == 'none') { div.style.display = ''; } else { div.style.display = 'none'; return false; } } </script> <style> div.g-recaptcha { margin: 0 auto; width: 304px; } </style> <form name="form2" method="post" onsubmit="showhide(); return true;" action="/bestanden/phps/jocanasnlsuggest.php"> ideeën voor nieuwe films, tv-series, games of functies:<br><textarea class="input" name="comment" rows="5" cols="30" required></textarea><br><br> <div class="g-recaptcha" data-sitekey="-----" data-theme="dark"></div> <div id="hidden_div" style="display:none"> <div class="spinner"> <div class="rect1"></div> <div class="rect2"></div> <div class="rect3"></div> <div class="rect4"></div> <div class="rect5"></div> </div> </div> <div id="hidden_div" style="display:block"> <input type="submit" value="voorstellen" name="submit"> </div> </form>
you can provide new id submit button's div block , can write logic in same function. there no need function.
<div id="hidden_div1" style="display:block"> <input type="submit" value="voorstellen" name="submit"> </div>
and in showhide() function:
var div1 = document.getelementbyid("hidden_div1"); div1.style.display='none';
the working plunkr here:https://plnkr.co/edit/t18obhp0xxyptzmf3ppn?p=preview
Comments
Post a Comment