开发者

Running HTML/JavaScript in a Perl File

开发者 https://www.devze.com 2023-01-24 12:06 出处:网络
I have an array in my Perl file that I\'m using to populate a drop down menu in another PHP page. So I have a perl.pl file that is called by ---> php.php. Now, this is the code in my PHP file

I have an array in my Perl file that I'm using to populate a drop down menu in another PHP page.

So I have a perl.pl file that is called by ---> php.php. Now, this is the code in my PHP file

$output = shell_exec("/usr/bin/perl perl.pl $arg1 $arg2");
echo $output;

In my Perl file, this is what I pass at the end to get the dro开发者_开发问答p-down menu:

    print "<SELECT id='process_type'>\n";
    foreach $value (@xvalues) { 
        #Removing any trailing white spaces from the option list
        $value_no_space =~ s/\s+//g;
         print "\t<OPTION value='$value_no_space'>$value</OPTION>\n";
         $i++;
    }
    print "</SELECT>\n";
    my $s = document.getElementById('process_type');
    print $s;
    print "\n";

I was hoping that when I selected an option from the menu on the PHP page, that variable would come back to and be stored in $s. However, this is not the case. I do understand that PHP is client side and Perl is server side, so thats why I'm unable to get the result back. Is there a work around? I really do need to have the selected option in the same Perl file in order to complete some other tasks I need to do ...


PHP is server side - I think you are confusing PHP with JavaScript.

To get it available serverside, give your select a name attribute.

For what reasons are you executing that portion of code with Perl via PHP system call?

I think what you want is best to handle all the HTML output and POST handling with PHP. Then you can use your Perl graphing utility after.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号