Hi All, I have a small CGI script which creates a small hash. I want to retrieve values from the hash in javascript.
A snippet of my code is as follows: <CODE> use CGI; my $q = new CGI; print $q->header; print qq[<body> <form name='myForm'> ]; my %hash = qw ( ONE 1 TWO 2 THREE 3 ); print qq[<select name='sel' onChange=populate()>]; foreach my $key (keys %hash) { print qq[<option value='$key'>$key</option>]; } print qq[</select>]; print qq[<input type='submit' value='Go'> </form> </body>]; print qq[<script language='javascript'> function populate () { with (document.myForm) { var str = sel.options[sel.options.selectedIndex].value; alert (str); // will show ONE, or TWO.... // Now I want to retreve value for the str selected var num = '$hash{str}'; // I have even tried.. // var num = 'hash{'+str+'}; } } </script> </html> ]; </CODE> Can Anyone please point out how to retrieve the hash values so I can print 1,2,3.. Thanks in advance, Parvez ____________________________________________________________ Find what you are looking for with the Lycos Yellow Pages http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10 _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs