Solved

How to create a hidden IFrame submit a form

Posted on 2004-04-19
7
2,939 Views
Last Modified: 2007-11-27
I have a HTML form which will submit to a DLL file originally. Now I need to amend the logic that when the user clicks the submit button at the orginal HTML form, it will submit to one more asp too.

What I can think of to reduce the impact on the logic and screen layout is to

1. create a hidden IFrame
2. create a Form with pre-defined Hidden values
3. when user clicks the submit button, the values are then passed to the form at the IFrame and then submit too

Is it practical? If yes, any sample coding I can reference from?

Thanks!
0
Comment
Question by:mscprojhk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 10858183
That's possible. Though, why create an IFRAME? You can make another form at top or bottom of page with display:none that would take up no space. This is how you can do it.

<form name="form1" action="something.dll" onSubmit="document.form2.submit();">
<!-- or document.all.form2.submit() but try it without the .all first -->
<input type="text">etc.etc.
</form>
<form style="display:none;name="form2">
<input type="hidden">etc.etc.
</form>
0
 

Author Comment

by:mscprojhk
ID: 10865624
but, i'm afraid that if the second is using a hidden form, when i submit the 2nd form first, it may already redirect the page to the form action asp. then, i can't submit the 1st form then.

that's why i try to use IFrame that even the 2nd form posted firstly, the result will be shown at the hidden IFrame only, and i can still submit 1st form.

am i right?
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 50 total points
ID: 10871886
Hmm... I see your problem. You can do it by doing this.

<form name="form1" action="something.dll" onSubmit="iframename.form2.submit();">
<!-- or document.all.form2.submit() but try it without the .all first -->
<input type="text" name>etc.etc.
</form>
<iframe src="testing4.html" name="iframename" height=0 width=0></iframe>

Now, in testing4.html, you put:

<form name="form2" action="someaction.asp">
<input type="text" name="">etc.etc.
</form>

This has been tested to work. If you change iframename, make sure to change it in the onSubmit and the IFRAME tag. If you change form2 as the name as the form in testing4.html, make sure the form2 in the onSubmit is changed also. Everything else you should know how to modify.

Hope this helps. Good luck.

--Zyloch [Note: I have noticed many people using the Hope this helps thing too... I might have to think of a better slogan.]
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 10871925
Second Note: Please ignore the comment in the above HTML code; it wasn't changed.

In case you were wondering how I tested it, I tested it by having an IFRAME as a form. Both forms had actions that were HTML documents. The hidden IFRAME form had an action to an HTML page that held a <BODY onLoad="window.location.href='http://www.google.com;'">. This should still work even if your IFRAME ASP form redirects the page somewhere else.

--------------------------------------------------------------------------------

Of course, the answer can also be 42 (Hitchhiker's Guide to the Galaxy)-Not a real answer.

--Zyloch. [My newest slogan...]
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 11310561
Zyloch: http can do one request at a time. So two forms submitted to the same window will interfere...
The iframe solution is better.

Michel
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.net Markup for Sub Menu 2 63
Debugging Html 8 40
Html split(text) Part2 6 39
title attribute 5 33
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question