Sathya Raj
Sathya Raj

Reputation: 1089

Refresh Form page after submitting the form?

I use target="_blank" for my form submission to open the resulting page in new window but the previous or form page is still open and holding the values filled for form submission . If i click submit again it submits again with same values, so how would i refresh form page after submission.

<form target="_blank" id="monthly_form" method="post" action="<?php echo base_url().'billing/monthly_slip'; ?>">
..form fields
...
</form>

Upvotes: 2

Views: 20331

Answers (4)

D.Snap
D.Snap

Reputation: 1780

<form method="post" onsubmit="window.location.reload()">
<input type="submit" value='go' />
</form>

Upvotes: 1

Alex Art.
Alex Art.

Reputation: 8781

window.location.reload()

should work

Upvotes: 3

Nil&#39;z
Nil&#39;z

Reputation: 7475

Do not use target="_blank" for form submission, Instead post the form normally and redirect from controller. But if you really need to use target="_blank" then after form submit just reload the page or reset the form.

Upvotes: 0

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

try something like:

$(document).ready(function() {
    $('#your_form_id').on('submit', function(evt) {
          evt.preventDefault();
          setTimeout(function() {
               window.location.reload();
          },0);
          this.submit();
    });
});

Upvotes: 3

Related Questions