Is there any way to submit the form to an Iframe (without Javascript)?

2

Is there any way to do a form submission where action , instead of refreshing the page, is submitted to iframe ?

I have seen this somewhere, but I did not know how the magic was done. It was done without Javascript.

Something like:

<form action="/my_page" method="POST">
    <input type="text" name="name" />
    <input type="submit" value="Submit" />
</form>
<!-- o resultado deve ser exibido aqui, ao invés de atualizar a página -->
<iframe></iframe>

How can I do this?

    
asked by anonymous 24.11.2016 / 11:49

1 answer

1

Yes, there is a way to submit a form to a iframe , without Javascript.

Many people do not know, but it is possible.

First, you must set the target attribute to its form . This target should point to the desired iframe . Therefore, you need to set name to iframe where you want the submission to be processed. Then, in form you set the target attribute to the value of name assigned to iframe .

See:

<form action="/my_page" method="POST" target="target_iframe">
    <input type="text" name="name" />
    <input type="submit" value="Submit" />
</form>
<!-- o resultado deve ser exibido aqui, ao invés de atualizar a página -->
<iframe name="target_iframe"></iframe>

In the above case, the result of the submission that will be processed in the url /my_page would be displayed within iframe without page refresh .

    
24.11.2016 / 11:49