#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Phoenix, AZ
    Posts
    3
    Rep Power
    0
    Is there a way to call perl functions from javascript functions?

    I'd prefer to do this in a way other than doing posts or gets.

    Any help would be appreciated.

    Here's my so-so example. Does this help explain my problem?

    calling method => SaveData(this.form);
    // in the form i've declared a bunch of
    // inputs name=accesslist[] value=1..
    function SaveData (f) {
    // perl function to save array to file
    savearray(f.accesslist[]);
    }

    # perl function
    sub savearray {
    my (@arraytosave) = (@_);
    $FILEOUT = '>tmp.txt';
    open(OUT, $FILEOUT) die "Can't open file";
    foreach $arrayelem (@arraytosave) {
    print OUT "$arrayelemn";
    }
    close OUT;
    }


    [This message has been edited by Crios (edited September 19, 2000).]
  2. #2
  3. SwollenMember
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    the master control
    Posts
    264
    Rep Power
    15
    yes...i think i understand what you are asking and it can be done...could you give a specific example of what you are trying to achive?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    82
    Rep Power
    15
    Uh, I am pretty sure you are not going to be able to do this. JavaScript is a client side language, where as Perl is most likely going to be on your server side.

    It would probably be easier for you to use a JS redirect to bounce off a perl script.

    [This message has been edited by JSchoof (edited September 20, 2000).]
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    15
    Actually I thought it wasn't possible untill ysetderday. Someone accidentally showed me how to do it.

    - Make a perl-script that outputs Javascript.
    - Put this in your cgi-bin directory.

    - Call this script like <SCRIPT LANGUAGE="Javascript" SRC="cgi-bin/yourscript.pl"></SCRIPT>

    - Use the variables that are made declared by the perl-script in your next script tag.

    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl

IMN logo majestic logo threadwatch logo seochat tools logo