form submission to two pages (Perl, CGI, JavaScript)

C

ccc31807

I have a rather long list, perhaps named 'list_presidents' that allows users to update single records. It might look like this, with the convention that [[input text][submit N]] is an HTML form:

1 | George Washington | [[input text][submit 1]]
2 | John Adams | [[input text][submit 2]]
3 | Thomas Jefferson | [[input text][submit 3]]
4 | James Madison | [[input text][submit 4]]

The form field looks like this:
<form method="post" action="update_pres" name="pres_N">
....
<input type="submit" value="Update President N" />
</form>

I would like to do one of three things but quite frankly don't know how. This post is the culmination of a fairly long time flailing around, and I'd like a little help --- even if it's confirmation that what I want is not possible (which I'm beginning to suspect is the case.)

1. When the user clicks on the submit button, leave the user on the same page but execute a script in the background that updates the underlying database.

2. When the user clicks on the submit button, leave the user on the same page but open a new page that confirms that the database has been updated.

3. When the user clicks on the submit button, go to a new page that confirms the update but then immediately returns to the prior page.

The problem is that the table has about 40,000 records, and there are aboutsix filters, some of which have fifty or so options, and they all can be multiply selected. It was a lot faster and simpler when I had just a couple of thousand records and a couple of simple filters, but this has grown froma sweet innocent baby to a strapping adult man, and I need some help with it.

Thanks, CC.
 
J

J. Gleixner

I have a rather long list, perhaps named 'list_presidents' that allows users to update single records. It might look like this, with the convention that [[input text][submit N]] is an HTML form:

1 | George Washington | [[input text][submit 1]]
2 | John Adams | [[input text][submit 2]]
3 | Thomas Jefferson | [[input text][submit 3]]
4 | James Madison | [[input text][submit 4]]

The form field looks like this:
<form method="post" action="update_pres" name="pres_N">
...
<input type="submit" value="Update President N" />
</form>

I would like to do one of three things but quite frankly don't know how. [...]>

None of these really has anything to do with Perl/server side...
1. When the user clicks on the submit button, leave the user on the same page but execute a script in the background that updates the underlying database.

2. When the user clicks on the submit button, leave the user on the same page but open a new page that confirms that the database has been updated.

3. When the user clicks on the submit button, go to a new page that confirms the update but then immediately returns to the prior page.
That last one and it would make for a poor user experience.

Read up on AJAX. A JavaScript framework, like JQuery, makes doing these
things much easier than writing it yourself. There are many JavaScript
libraries that you can choose from and they each simplify AJAX calls,
going through the DOM, validating forms, dynamically show/hide
elements, etc. Other popular libs: Ext JS, MooTools, Prototype,
GWT, YUI, etc....

See: http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top