473,378 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

jQuery: recreating a form's contents in hidden fields on a 2nd page

25
I have a CGI-style web application using static HTML (an SAS IntrNet app) that submits a form to the server and then gets a report back.

I want to change it so that the output is opened in a separate window which gets created using JavaScript.

That means I need to grab all the form selections and hidden fields and pass them to the new window, plug them into a new form and submit to the server.

What's the best way to do this? Is this the most efficient way?

1. Loop through the form using jQuery and populate a querystring variable with all the form elements' names & values. (Note: Some are multi-option select boxes.)
2. Open up the new window with that querystring.
3. Loop through that querystring and dynamically add a hidden field to the window's form for each element.
4. Submit the form from the window to the server.

Are there any gotchas I need to be aware of? Can hidden fields take the place of multiple-value select boxes, for example?

I've figured out how to loop through the form using jQuery and create the querystring. Now, I just want to make sure the final step--impersonating the original form--is doable, too.

Thanks.
Mar 18 '11 #1

✓ answered by acoder

Instead of that, why can't you set the target attribute so that it opens in a new window (avoiding the need for any JavaScript)?

6 1833
acoder
16,027 Expert Mod 8TB
Instead of that, why can't you set the target attribute so that it opens in a new window (avoiding the need for any JavaScript)?
Mar 21 '11 #2
svendok
25
Man, I'm an idiot. That's so simple, it's obscene. Thank you!
Mar 21 '11 #3
acoder
16,027 Expert Mod 8TB
No problem. Sometimes it's just a case of finding a simpler solution. Having said that, it may be an idea to solve the problem that you posed to improve your skills/expertise.
Mar 22 '11 #4
svendok
25
True. The target solution isn't perfect in this case, since IE doesn't allow you to close that window using window.close() (FF does). So the IE user has to click a confirmation message every time. But I can live with that for now.
Mar 24 '11 #5
acoder
16,027 Expert Mod 8TB
You can use window.open() with the window name and then use that as the target in the form. See https://developer.mozilla.org/en/DOM...and_parameters
Mar 25 '11 #6
svendok
25
Hmm, the plot thickens. Thank you yet again!
Mar 25 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ryann | last post by:
Hello. I am creating a form that has 5 steps/pages. Each page contains about 20 fields. But I don't want to write them until they submit on the last page. I figured out that I can use hidden...
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
1
by: Sam Wuebben | last post by:
I would like to add a few hidden field values to a form as it is submited via JavaScript. I have a static page shopping site that uses MIVA shopping cart. Some of the pages are getting quite...
5
by: sams | last post by:
I've seen this covered before, but I just don't understand Java very well. I apologize if this is a repeat. Basically, I need a text/java style submit form with multiple hidden fields. It would...
5
by: NTE | last post by:
Access 2000, My application has a main form that the users interact with. There are 2 hidden fields. When they select "filter by form" from the menu, the hidden fields become visble. Is...
5
by: Roshawn Dawson | last post by:
Hi, Are hidden fields passed in the querystring when a form is posted back? If they are, must the hidden fields be server controls in order to access them from .net code? Thanks, Roshawn
3
by: HockeyFan | last post by:
I know that <input type="hidden" fields are used within a form, but do <ASP:HiddenField s have to be in a form to be used? I've got a VB-based (codebehind) that catches the click event of a button...
5
by: HockeyFan | last post by:
I know that <input type="hidden" fields are used within a form, but do <ASP:HiddenField s have to be in a form to be used? I've got a VB-based (codebehind) that catches the click event of a button...
7
by: cartercc | last post by:
I think I already know the answer to this one, but I'm giving it the old college try. My problem is this: I have an HTML form that sends a bunch of data to a Perl script, where it is validated...
1
by: jamestpaul | last post by:
I'm having some difficulty with Safari users and hidden fields in my .NET 2 asp application. There is a hidden field that gets loaded with the contents of a div in my form. When the user submits...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.