Solved

How to create a hidden IFrame submit a form

Posted on 2004-04-19
7
2,935 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 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