473,398 Members | 2,404 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,398 software developers and data experts.

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


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
6 1680
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
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

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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sandman | last post by:
The subject says it all. I am doing a: I have a perl script in which I am using a ReadParse routine that parses the $ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed...
58
by: @ | last post by:
A benchmark in 2002 showed PHP is much slower in shell or when Apache has Mod_Perl. With the new PHP kissing Java's ass, Perl is once again the #1 CGI choice. Java is for a big team in short...
42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
5
by: howachen | last post by:
Currently I only use Ultra-Edit to write Javascript and debug using the firefox JS debugger. But as the project goes complex, I need to have a more advance editor, such as class/methods...
3
by: MarkW | last post by:
I hope this is the correct place to post this: I am developing a web site for a e-commerce business I will be running. The site I'm setting up will be 50% store, 50% content. I'm not sure which...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.