esafwan
esafwan

Reputation: 18029

Submitting a form in Iframe by Jquery and get the returned value

Im having a webpage with an iframe with form in it. I want to submit the form and get the result. How can i do it with jquery?

<iframe src ="html_intro.asp" width="100%" height="300">
  <form action="submit.php">
  <input type="text" name="name" />
  </form>
</iframe>

Upvotes: 1

Views: 6750

Answers (2)

Sarfraz
Sarfraz

Reputation: 382746

Try this:

$('#iframe_id').contents().find('form')[0].submit();

It is assumed that your are NOT hosting other domain in your iframe.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038930

If the iframe is hosted on a domain different than the parent domain you cannot manipulate it with javascript. To submit the form from within the iframe you could use the submit method:

$('#yourFormId').submit();

Upvotes: 0

Related Questions