By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

avascript w/Perl question - Simple for most......

P: n/a

Hi All,

I have a form that uses Javascript to validate some fields. Whe the
user selects to submit the form with certain values selected, I want to
be able to execute a Perl script, query the MySQL database to get my
resuts and return an ALERT box to the user if his form input was
invalid.

Problem is, I do not want to change the screen. I just want the dialog
to pop up. I am very good at Perl, but I'm less than a novice at
Javascript. I was hoping that if someone had an exmple of this, they
could put it up and explain it to me........

Thanks,

Arthur

Jan 30 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
am****@iwc.net wrote:
Hi All,

I have a form that uses Javascript to validate some fields. Whe the
user selects to submit the form with certain values selected, I want to
be able to execute a Perl script, query the MySQL database to get my
resuts and return an ALERT box to the user if his form input was
invalid.

Problem is, I do not want to change the screen. I just want the dialog
to pop up. I am very good at Perl, but I'm less than a novice at
Javascript. I was hoping that if someone had an exmple of this, they
could put it up and explain it to me........

Thanks,

Arthur

You would need to use XmlHTTPRequest to send all the form fields to a
perl page that can check the input against the database/validation
functions, and either return OK to submit, or return false for a
particular field name/number. This is also known as AJAX.
http://www.w3schools.com/xml/xml_http.asp

Or instead of doing all the form fields at once, you could to the
validation onblur for each form field. However, if the server response
is slow, this will probably be annoying.

Jan 30 '06 #2

P: n/a
jshanman said the following on 1/30/2006 3:01 PM:
am****@iwc.net wrote:
Hi All,

I have a form that uses Javascript to validate some fields. Whe the
user selects to submit the form with certain values selected, I want to
be able to execute a Perl script, query the MySQL database to get my
resuts and return an ALERT box to the user if his form input was
invalid.

Problem is, I do not want to change the screen. I just want the dialog
to pop up. I am very good at Perl, but I'm less than a novice at
Javascript. I was hoping that if someone had an exmple of this, they
could put it up and explain it to me........

Thanks,

Arthur

You would need to use XmlHTTPRequest to send all the form fields to a
perl page that can check the input against the database/validation
functions, and either return OK to submit, or return false for a
particular field name/number. This is also known as AJAX.
http://www.w3schools.com/xml/xml_http.asp


Why do people continue to make the mistake of thinking that
XMLHTTPRequest is the only way to do that? It's not. It is also not the
most widely supported way of doing it. One simple solution that comes to
mind is to submit a dummy form in a hidden IFrame and read the results
back from there.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 30 '06 #3

P: n/a

Randy Webb wrote:
jshanman said the following on 1/30/2006 3:01 PM:
am****@iwc.net wrote:
Hi All,

I have a form that uses Javascript to validate some fields. Whe the
user selects to submit the form with certain values selected, I want to
be able to execute a Perl script, query the MySQL database to get my
resuts and return an ALERT box to the user if his form input was
invalid.

Problem is, I do not want to change the screen. I just want the dialog
to pop up. I am very good at Perl, but I'm less than a novice at
Javascript. I was hoping that if someone had an exmple of this, they
could put it up and explain it to me........

Thanks,

Arthur

You would need to use XmlHTTPRequest to send all the form fields to a
perl page that can check the input against the database/validation
functions, and either return OK to submit, or return false for a
particular field name/number. This is also known as AJAX.
http://www.w3schools.com/xml/xml_http.asp


Why do people continue to make the mistake of thinking that
XMLHTTPRequest is the only way to do that? It's not. It is also not the
most widely supported way of doing it. One simple solution that comes to
mind is to submit a dummy form in a hidden IFrame and read the results
back from there.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Your right, its not the only way. Another way is outline in the
article linked below, which involved appending a child script that is
generated by a server page. The author claims that this is more
compatible then XmlHTTPRequest, however, it only supports GET requests.
Interesting technique, at least.

http://www.phpit.net/article/ajax-ph...mlhttprequest/

Jan 31 '06 #4

P: n/a
jshanman said the following on 1/31/2006 9:07 AM:
Randy Webb wrote:
jshanman said the following on 1/30/2006 3:01 PM:
am****@iwc.net wrote:
Hi All,

I have a form that uses Javascript to validate some fields. Whe the
user selects to submit the form with certain values selected, I want to
be able to execute a Perl script, query the MySQL database to get my
resuts and return an ALERT box to the user if his form input was
invalid.

Problem is, I do not want to change the screen. I just want the dialog
to pop up. I am very good at Perl, but I'm less than a novice at
Javascript. I was hoping that if someone had an exmple of this, they
could put it up and explain it to me........

Thanks,

Arthur

You would need to use XmlHTTPRequest to send all the form fields to a
perl page that can check the input against the database/validation
functions, and either return OK to submit, or return false for a
particular field name/number. This is also known as AJAX.
http://www.w3schools.com/xml/xml_http.asp Why do people continue to make the mistake of thinking that
XMLHTTPRequest is the only way to do that? It's not. It is also not the
most widely supported way of doing it. One simple solution that comes to
mind is to submit a dummy form in a hidden IFrame and read the results
back from there.


Your right, its not the only way. Another way is outline in the
article linked below, which involved appending a child script that is
generated by a server page.


Yes, and that page doesn't have a real good example of how to load
script files dynamically.
The author claims that this is more compatible then XmlHTTPRequest,
It is - when coded properly.
however, it only supports GET requests.
Ayup.
Interesting technique, at least.

http://www.phpit.net/article/ajax-ph...mlhttprequest/


Been doing that new "trick" for several years now.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 1 '06 #5

P: n/a
Randy Webb wrote:
jshanman said the following on 1/31/2006 9:07 AM:
Randy Webb wrote:
jshanman said the following on 1/30/2006 3:01 PM:
am****@iwc.net wrote:
> Hi All,
>
> I have a form that uses Javascript to validate some fields. Whe the
> user selects to submit the form with certain values selected, I want to
> be able to execute a Perl script, query the MySQL database to get my
> resuts and return an ALERT box to the user if his form input was
> invalid.
>
> Problem is, I do not want to change the screen. I just want the dialog
> to pop up. I am very good at Perl, but I'm less than a novice at
> Javascript. I was hoping that if someone had an exmple of this, they
> could put it up and explain it to me........
>
> Thanks,
>
> Arthur

You would need to use XmlHTTPRequest to send all the form fields to a
perl page that can check the input against the database/validation
functions, and either return OK to submit, or return false for a
particular field name/number. This is also known as AJAX.
http://www.w3schools.com/xml/xml_http.asp
Why do people continue to make the mistake of thinking that
XMLHTTPRequest is the only way to do that? It's not. It is also not the
most widely supported way of doing it. One simple solution that comes to
mind is to submit a dummy form in a hidden IFrame and read the results
back from there.
Your right, its not the only way. Another way is outline in the
article linked below, which involved appending a child script that is
generated by a server page.


Yes, and that page doesn't have a real good example of how to load
script files dynamically.
The author claims that this is more compatible then XmlHTTPRequest,


It is - when coded properly.
however, it only supports GET requests.


Ayup.
Interesting technique, at least.

http://www.phpit.net/article/ajax-ph...mlhttprequest/


Been doing that new "trick" for several years now.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Been doing that new "trick" for several years now.

You've also probably been programming for longer then I've been alive
:)

I've never used the iFrame method, but I've done a few tests to compare
the appendChild and XMLHttpRequest, which turned out to be equally
efficient for GET requests.

In your opinion, which way is better, the iframe, appendChild, or
XMLHttpRequest?

Feb 1 '06 #6

P: n/a
jshanman said the following on 2/1/2006 8:47 AM:
Randy Webb wrote:
<snip>
Been doing that new "trick" for several years now.

You've also probably been programming for longer then I've been alive
:)


<shrug> Possibly.
I've never used the iFrame method, but I've done a few tests to compare
the appendChild and XMLHttpRequest, which turned out to be equally
efficient for GET requests.
Did you test it in browsers that do not support XMLHTTPRequest? One
scenario that comes to mind is IE with ActiveX disabled but Scripting
enabled.
In your opinion, which way is better, the iframe, appendChild, or
XMLHttpRequest?


The IFrame is the most reliable and cross-browser if you are wanting to
do POST and GET's with Forms.

But it all goes back to what you are trying to accomplish. But to use
"AJAX" simply so you can say "Hey, I use AJAX" isn't using much brain
power.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 2 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.