in reply to Re: passing variables from cgi to javascript
in thread passing variables from cgi to javascript

ah, okay - i don't think i phrased the question very well.

the cgi script has to initialise the second list to empty values, so there's nothing to take from the second drop down menu. my question is really - how do i create a javascript array from a perl array?

thanks

  • Comment on Re: Re: passing variables from cgi to javascript

Replies are listed 'Best First'.
Re: Re: Re: passing variables from cgi to javascript
by fruiture (Curate) on Sep 18, 2002 at 19:48 UTC

    That should be done like in the writeup of LTjake Re: passing variables from cgi to javascript with an additonal escaping of quotes.

    my %hash = ( opt1 => [qw/these are the options of the dynamic select box when opt1 in the first is selected/], #... ); my $js = 'var items = new Array();'. map { "items['$_'] = new Array('". join("','",map quotemeta => @{$hash{$_}}). "');" } keys %hash;
    --
    http://fruiture.de