Calling Perl program from Java Script and populating the list boxes

Discussion in 'Perl Misc' started by alwaysonnet, Nov 3, 2006.

  1. alwaysonnet

    alwaysonnet Guest

    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
     
    alwaysonnet, Nov 3, 2006
    #1
    1. Advertising

  2. alwaysonnet <> wrote:

    > 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 ==>


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Nov 3, 2006
    #2
    1. Advertising

  3. alwaysonnet

    Guest

    "alwaysonnet" <> wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Nov 3, 2006
    #3
  4. alwaysonnet

    Guest

    On Nov 3, 8:59 am, wrote:
    > "alwaysonnet" <> wrote:
    > > Hi all,

    >
    > > Question 1 - Is it possible to call a perl subroutine from Javascript ?Not directly, ordinarily. Indirectly, sure.

    >


    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...
     
    , Nov 3, 2006
    #4
  5. alwaysonnet

    Guest

    On Nov 3, 12:41 pm, Christian Winter <> wrote:
    > 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.
     
    , Nov 26, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Mueller
    Replies:
    5
    Views:
    12,402
    jamesxa
    Jun 16, 2009
  2. Lamine Darbouche

    Populating three list boxes from the database

    Lamine Darbouche, Oct 6, 2003, in forum: ASP General
    Replies:
    2
    Views:
    124
    Lamine Darbouche
    Oct 8, 2003
  3. pj
    Replies:
    3
    Views:
    291
  4. kath
    Replies:
    4
    Views:
    647
    J. Gleixner
    Apr 9, 2007
  5. Yogi
    Replies:
    1
    Views:
    434
    Peter Makholm
    Sep 13, 2012
Loading...

Share This Page