View Full Version : targetting a form to an iframe

07-01-2004, 01:31 PM

I am trying to use remote scripting in my page and I ran into several problems.
My page is defined like so:

<form name="myForm" method="post" action="target.html" enctype="multipart/form-data" target="RSIFrame">
<input type="text" name="text"></input>
<input type="file" name="file"></input>
<input type="submit" value="submit"> </input>
<iframe id="RSIFrame" name="RSIFrame" style="width:0xp; height:0px; border:0px;"></iframe>

taget.html is defined like so:

<script type="text/javascript">
function processData() {
// -->
<body onload="processData"></body>

I am trying to cause the form to be submitted via the "hidden iframe". Once a response will return from the server in taget.html, a message should be displayed in the original window.

I have 2 problems:
1) The iframe is indeeded hidden, but still takes a space in the original window (note the 'Text' being displayed right after it). I would like to make it completely invisible. I heard that if I gave it the style: display:none, it will not work properly.
2) For some reason I am not getting the alert message to appear. I am not sure what the problem is. Maybe the form is not being submitted, or maybe the onload event is not triggered in target.html

please help

07-01-2004, 01:41 PM
<body onload="processData()"></body>

I think there's no problem with iframe with display:none property. Have you tried it?

Also, the form action should be a server-side script not static HTML as Javascript can't read POSTed data, much more a multipart one.

07-01-2004, 01:52 PM
thanks, I forgot the parentheses.
I was able to make the iframe invisible but setting its width and height to 0 like so:

<iframe id="RSIFrame" name="RSIFrame" width="0xp" height="0px" style="border:0px;"></iframe>

I was calling a static HTML file just to make the example simple. My actual code invokes a PHP page.

thanks again

07-02-2004, 11:28 AM
I'd like to point out a mistake:
<iframe id="RSIFrame" name="RSIFrame" width="0xp" height="0px" style="border:0px;"></iframe>Your mistake is highlighted in red, heres what it should be:
width="0px" :D

07-02-2004, 12:07 PM
thanks, you are right.
Eventually I decided to go with:

<iframe id="RSIFrame" name="RSIFrame" style="display:none"></iframe>

which also works fine

07-02-2004, 02:01 PM
OK I bet your glad you cleared that up aren't you :D