Open link in iframe after post PHP + JS [duplicate]

0

I asked another question here in the forum about another subject that helped me a lot about this however the link opens in a new page.

What I would like is that by clicking on the submit it would open inside an iframe inside the page and if the field was not filled it would receive a popup saying that the field was not filled ..

<?php
if (isset($_REQUEST['txt_url'])) {
$link = 'http://' . $_REQUEST['txt_url'] . '.datatix.com.br';
header('Location: ' . $link);
} 
?>

<div class="instancia">
<div class="content">
<img src="img/logo_datatix.jpg" height="32px">
<form action="" method="post">
<input type="text" name="txt_url" value="" placeholder="Digite sua Instância">
<input type="submit" value="Ok" name="ok "class="ok">
</form>
</div>
</div>

<div class="iframe">
<iframe id="conteudo_iframe"></iframe>
</div>

If possible do not use php would be much better.

It would be more or less what is in the code below, but the user does not put the entire domain just the subdomain.

Example: It puts "test" and "OK" but in the iframe it would load the link test.domain.com

body{ padding:0; margin:0;}
.instancia{ background-color:#D3172F; color:#FFF; font-family:Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif; width:100%; position:fixed; border-bottom:#9B1022 2px solid !important;}
.instancia .content{ width:320px; margin:0 auto; display:table;}
.instancia img{ float: left;}
.instancia input{ height:30px; padding-left:5px; padding-right:5px; width:176px; border:0; float: left;}
.instancia .ok{ border:0; background-color:#9B1022; height:32px; width:32px; color:#FFF; float:left; font-weight:bold; cursor:pointer;}
<div class="instancia">
<div class="content">
<img src="img/logo.jpg" height="32px">
<form action="" method="post">
<input type="text" name="txt_url" value="" placeholder="Digite sua Instância">
<input type="submit" value="Ok" name="ok "class="ok">
</form>
</div>


</div>

<div class="iframe">
<iframe name="exemplo" width="100%"></iframe>
</div>
    
asked by anonymous 05.11.2015 / 16:57

2 answers

1

Use the target attribute of link or the form , with value equal to the attribute name of <iframe>

<a href="http://pt.stackoverflow.com/" target="exemplo">pt.stackoverflow.com</a>
<form action="http://pt.stackoverflow.com/" target="exemplo">
  <input type="submit"/>
</form>
<iframe name="exemplo"></iframe>

Note: <iframe> will not finish loading due to OS restrictions, but saving content to an HTML file will work.

    
05.11.2015 / 17:13
0

Use the targert tag to identify what you want to open inside the iframe, if you want to do some other validation, create a function in onsubmit

    
05.11.2015 / 17:02