0

My code: <form method='post' target='_blank'... I have multiple of these forms on my page with the same action attribute.

Problem: Only one popup ever opens. If a second form is submitted, it replaces the first form's popup.

How do I get a new popup for each form? (Preferably without changing the action attribute.)

EDIT: I tried adding a random number (Math.floor(Math.random()*1000)) as a null parameter in the action url. This still opens in the same popup.

NOTE: There is no JS being used. However, I'd accept a JS answer.

1 Answer 1

1

Complete working code :-

<html>
<head>
<script>

function popup(form) {
    var popup_id = 'popup_'+form.id
    window.open(form.action, popup_id, 'width=400,height=400,resizeable,scrollbars');
    form.target = popup_id;

}
</script>
</head>
<body>
<form id="form1" action="page.php" onsubmit="popup(this); return false;">

<input type="submit" value="save" />
</form>

<form id="form2" action="page.php" onsubmit="popup(this);return false;">

<input type="submit" value="save" />
</form>
</body>
</html>
4
  • Identical behavior. :(
    – GiantDuck
    Jul 15, 2014 at 23:36
  • Then something else is causing "unexpected" behavior. How are your generating your popup ?
    – Samosa
    Jul 15, 2014 at 23:40
  • It's just when the user submits the form.
    – GiantDuck
    Jul 15, 2014 at 23:42
  • I'm not using any JS here.
    – GiantDuck
    Jul 16, 2014 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.