September 19th, 2000, 10:23 AM
-
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).]
September 19th, 2000, 11:56 AM
-
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?
September 20th, 2000, 08:19 AM
-
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).]
September 21st, 2000, 02:13 AM
-
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