Form submit, target iframe, opens in new window, but i dont want it to?

Hi, I have a form that im submitting to an iframe on the same page, but when the form is submitted, it opens a new window? I have tried both GET and POST methods and both do not work :frowning:

Can anyone point me in the right direction? Here is an example of what im doing.

Thanks in advance for any help.

<form action="" method="post" target="frame">
<input name="q" type="text" id="q" />
<input name="google" type="checkbox" value="1" />
<input value="Search" type="submit">
</form>

<iframe src="http://www.google.com/search?q=<?php echo $_POST["q"]; ?>" width="800px" height="500px" id="frame" frameborder="0"></iframe>

I think this is better answered in the PHP forum, but here is a suggestion:


<form action="<?php  $_SERVER["PHP_SELF"]; ?>" method="post">
<input name="q" type="text" id="q" />
<input name="google" type="checkbox" value="1" />
<input value="Search" type="submit"/>
</form>
<iframe src="http://www.google.com/search?q=<?=$_POST["q"]; ?>" width="800px" height="500px" frameborder="0"></iframe>

Thnaks for your reply erik.j, unfortunatly i tried your theory and it doesnt work :frowning:

Sorry, missing shorthand echo in form action.

<form action="<?=  $_SERVER["PHP_SELF"]; ?>" method="post">
<input name="q" type="text" id="q" />
<input name="google" type="checkbox" value="1" />
<input value="Search" type="submit" />
</form>
<iframe src="http://www.google.com/search?q=<?= $_POST["q"]; ?>" width="800" height="500" frameborder="0"></iframe>

Still doesnt work, it opens in a new window.

Thanks for input.

Maybe i need Javascript to target the iframe?

It should work, as stand alone anyway.

No javascript is needed, the page should reload and echo the parameter to google in iframe.

Ahh your right, i didnt take awat the target=β€œframe” in my form, thats why it didnt work.

Thankyou so much for your help Erik, its much appreciated my friend!

Glad to hear it worked!