0

Hi I am new to javascript I wanted to submit my form twice when i clicked sumbit button if someone can advice me how to implement it using javascript. I will really appreciate it. Thankyou

<script>

  $( document ).ready(function() {

      $("#submit").on('submit', function(event) {
  event.preventDefault();
  event.stopImmediatePropagation();
});


});
</script>

my button is this

<input id="submit" name="submit" class="form-button btn button" type="submit" value="Save">
aika aika
  • 51
  • 6
  • That should be easy enough to do - but I have to ask, why do you want to do this? – Robin Zigmond Nov 27 '18 at 21:52
  • It's difficult to understand what are you trying to achieve here. Anyways - you are apparently missing something to handle the form after submit, because as for now, you are doing nothing with the form after submit. – kind user Nov 27 '18 at 21:53
  • because I dont know also why I cannot fetch my data in the form if I wouldnt click the button twice – aika aika Nov 27 '18 at 21:54
  • The easiest way would be to basically invoke the function responsible for e.g. sending the data from the form somewhere twice, inside the submit function. – kind user Nov 27 '18 at 21:55
  • basically when you do a form submit, the page will "redirect" to the handler's page. so you can't do that twice with this kind of submit. However, you can call a javascript function that will do an "ajax" post (which is same as submit) and then you can do as many times as you want, and you would be able to control the result and even makes changes if you wish. So yeah, it is possible, but not in the methood of normal submit. again: you'll need: onsubmit = "runsomefunction(); return false"; and that function will do an ajax call with a POST methood and you'll be able to control result. – Kosem Nov 27 '18 at 22:05
  • thank you very much for the response to my question I really appreciate it it not possible to like create a function when button click submit clicked then the button will be clicked again? – aika aika Nov 27 '18 at 22:15
  • Possible duplicate of [How to submit a form using javascript?](https://stackoverflow.com/questions/9855656/how-to-submit-a-form-using-javascript) – vandench Nov 28 '18 at 01:07

0 Answers0