Calling Perl program from Java Script and populating the list boxes

A

alwaysonnet

Hi all,

Question 1 - Is it possible to call a perl subroutine from Javascript ?
Question 2 - Please provide an idea of how to build dynamic list boxes
using Javascript.

I have 2 list boxes containing Origin and Destination of flights. If i
select one Origin country then , second list box must populate only
those countries which have flights.

In the http://www.ryanair.com/site/EN/ site, If I select "Aarhus" as
origin and it will show only 2 countries "Barcelona" & "London". When i
see the code, it has pre-assigned arrays, whenever OnClick is triggered
it is calling the function and populating the array values.

But i need to populate the destinations from the database everytime i
select the origin from the listbox 1. Simply saying that I can't
hardcode the origin and destination arrays , as i need to get them from
the database...

Any help or suggestions are appreciated...

Thanks,
Raj
 
T

Tad McClellan

alwaysonnet said:
Question 1 - Is it possible to call a perl subroutine from Javascript ?


No.

But it is possible for Javascript to issue an HTTP request and the
destination server can write the code to handle that request in
just about any programming language, including Perl.

Question 2 - Please provide an idea of how to build dynamic list boxes
using Javascript.


This is the Perl newsgroup.

The Javascript newsgroup is over thataway ==>
 
X

xhoster

alwaysonnet said:
Hi all,

Question 1 - Is it possible to call a perl subroutine from Javascript ?

Not directly, ordinarily. Indirectly, sure.

....
But i need to populate the destinations from the database everytime i
select the origin from the listbox 1. Simply saying that I can't
hardcode the origin and destination arrays , as i need to get them from
the database...

The fact that you need to get them the database does not preclude you from
doing what you call "hardcoding". You would merely have to make Perl write
the "hardcoded" javascript. Maybe there are other reasons not to
"hardcode" them, but this isn't one of them.


Xho
 
K

krakle

One cheap way is to...

Create a Perl script outputting the JavaScript coding to write the HTML
coding for the list box. Name it blah.js. Then create an .htaccess file
setting .js scripts as executable Perl/CGI scripts. Then use <script
language="JavaScript" src="blah.js"></script> where ever you wish to
have the listbox display in your HTML document...
 
K

krakle

There's absolutely no need to mess with file extensions on the
server side. Every halfway decent browser will take any extension
the server uses for its CGIs or applications, as long as the
returned Content-Type: header and the HTML attribution for the
script tag are correct.

The server will NEVER execute the .js file as a CGI script unless you
change the type with the server to a cgi executable. If you leave it
alone (as you suggest) it will simply serve the .js as text including
the Perl code.
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top