Perl, javascript and CGI

Discussion in 'Perl Misc' started by Saya, Sep 5, 2003.

  1. Saya

    Saya Guest

    Hi,

    I have the following scenario in a system that we run. From a webpage
    using javascript I am able to invoke a *.ipl script on the server and
    pass parameters as well:

    javascript param parsing:
    parameters = new Object();
    parameters.iw_arrArtikelIDs = arrArtikelsToExtract;
    callServer("test.ipl", parameters, true);

    *.ipl param extraction:
    my${cgi} = new CGI();
    my $arrArtikelIDs = ${cgi}->param('iw_arrArtikelIDs');

    The issue here is that arrArtikelsToExtract is a java array containing
    ID's that I need to process in the *.ipl script. I can't seem to get
    it to work.
    I thought I was so lucky that I could get away with saying something
    like the below in the *.ipl script:
    my @arrArtikelIDs = ${cgi}->param('iw_arrArtikelIDs');

    Does anyone have any hints/clues/way(s) of achieving this. Parsing an
    array from javascript to an ipl script ?
     
    Saya, Sep 5, 2003
    #1
    1. Advertisements

  2. Saya

    Mark Guest

    Hi Saya,

    I am not an expert at these things but you might want to try this perl
    code to get hold of the parameters. It does not require you to specify
    the parameters by name

    ######Get the data from the form
    my $query = new CGI;
    my @keywords = $query->param;
    my $sizeKeywords = @keywords;

    #####put key value pairs returned from form into a hash
    my %values;
    foreach my $val(@keywords){
    $values{$val} = $query->param("$val");
    }

    If its the javascript that is not operating as expected, what about
    using a document.write statement to write a form action url with
    keyvalue pairs attached or to write hidden inputs within the form with
    each value of the array in a seperate input?

    Hope that helps,

    Mark
     
    Mark, Sep 5, 2003
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.