Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    targetting a form to an iframe

    Hello

    I am trying to use remote scripting in my page and I ran into several problems.
    My page is defined like so:
    Code:
    <html>
      <body>
        <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>
        </form>
        <iframe id="RSIFrame" name="RSIFrame" style="width:0xp; height:0px; border:0px;"></iframe>
         Text
      </body>
    </html>
    taget.html is defined like so:
    Code:
    <html>
      <head>
        <script type="text/javascript">
          <!--
          function processData() {
            window.parent.alert("back");
          }
          // -->
        </script>
      </head>
      <body onload="processData"></body>
    </html>
    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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    <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.

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, I forgot the parentheses.
    I was able to make the iframe invisible but setting its width and height to 0 like so:
    Code:
    <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

  • #4
    New Coder
    Join Date
    Jun 2004
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd like to point out a mistake:
    Code:
    <iframe id="RSIFrame" name="RSIFrame" width="0xp" height="0px" style="border:0px;"></iframe>
    Your mistake is highlighted in red, heres what it should be:
    Code:
    width="0px"

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, you are right.
    Eventually I decided to go with:
    Code:
    <iframe id="RSIFrame" name="RSIFrame" style="display:none"></iframe>
    which also works fine

  • #6
    New Coder
    Join Date
    Jun 2004
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK I bet your glad you cleared that up aren't you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •