Can I write to a div using Perl, or otherwise solve my form submission problem?
July 24, 2008 12:11 PM Subscribe
Can I write to a div using Perl, or otherwise solve my form submission problem?
I have a Perl/CGI form mailer script that I didn't write and shouldn't edit too much, but can somewhat.
It's currently set up so that I can define the thank you page and error page within the Perl file. I don't want it to redirect to those pages however. I want to display the messages on the page the form is on instead, without reloading if possible. I played around with redirecting to the same page but appending a parameter in the URL. Then using JS to show a div if that var was set. But I'm realizing I need to display some of the items submitted from the form and I don't know how to keep those values since the page is being refreshed.
I don't know Perl so I don't know if there is a better way to do this, but can I do something like write to a div with Perl? Other ideas?
posted by unsigned to computers & internet (5 answers total) 1 user marked this as a favorite
If you're handy with AJAX (and you'll have to be if you have you have your heart set on "without reloading if possible"), you could strip out all the html from the thanks/error pages except the actual message part. Then have the form make the ajax call and update a (previously empty) div with the returned message. Should be fairly simple if you use something like prototype.js.
(My perl skills ain't much either, but I expect people that do know it will need to see the actual code before making perl-specific recommendations. The main question being is the html output nicely separated from the perl logic.)
posted by danOstuporStar at 12:38 PM on July 24, 2008