0

I want to submit my form to an iframe, but it does not work. It instead opens in a new tab. How can I do it? Thanks

<form action="https://cp.payguru.com/" method="post" id="paymentData" target="FormFrame">
  @foreach (var item in data)
  {
    <input type="hidden" name="@item.Name" value="@item.Value" />
  }
  <hr/>
  <div class="text-center"><input type="submit" value="Devam Et" class="btn btn-primary" /></div>
</form>
<iframe id="FormFrame"></iframe>
Rory McCrossan
  • 306,214
  • 37
  • 269
  • 303

1 Answers1

2

The issue is because when posting from a form to an iframe, the target of the form needs to be set to the name of the iframe, not the id:

<iframe id="FormFrame" name="FormFrame"></iframe>
Rory McCrossan
  • 306,214
  • 37
  • 269
  • 303