Solved

How to create a hidden IFrame submit a form

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
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 the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

724 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