Hi, i am trying to set the src of a iframe on submitting a form.
Here is the code :
The js function is being called but the src attribute is not set and an other iframe is created within the iframe. I want to set the src only on form submit. How do i fix this? Thanks.
Here is the code :
Code:
<html> <head> <script type="text/javascript"> function changeSrc() { alert("Hello"); document.getElementById("myframe").src="http://google.com"; } </script> </head> <body> <form onsubmit="changeSrc()" target="myframe"> <!--<input type="button" onclick="changeSrc()" value="Change Source" /> --> <input type="submit" value="Change Source" /> </form> <iframe id="myframe" name="myframe"> <p>Your browser does not support iframes.</p> </iframe> <br /><br /> </body> </html>
Comment