How can I do two actions at the same time with one form and one submit button?

Asked 2 years ago, Updated 2 years ago, 37 views

Hi, everyone.

If you press one form and one submit button, I want to do two actions at the same time, what should I do?

<script>
function test(){
      document.forms['write_action'].action='Address1';
      document.forms['write_action'].target='_blank';
      document.forms['write_action'].submit();

      document.forms['write_action'].action='Address2';
      document.forms['write_action'].target='_self';
      document.forms['write_action'].submit();

}
</script>
<form method="post" id="write_action">
<input type="submit" onclick="test()">
</form>

I made it roughly like this. If you press the button, only "Address 1" goes in twice. <

How can I enter address 1 and address 2 at the same time with one button? <

php javascript jquery html

2022-09-22 16:51

1 Answers

It is right to take only one action in one form. If you want to take two actions with just one form, I think you can call the first action to ajax and call the second action to ajax again with the callback function when the submission is successful.


2022-09-22 16:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.