Solved

How to create a hidden IFrame submit a form

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now