Kristian Nilssen wrote:
> So how can I access a mason array using a javascript indexer? (see the WHAT 
> in 
> code sample) ...
> <script type="text/javascript">
>   var size = <% scalar @sortedfiles %>;
>   var imagearray = new Array(size);
>   // do the for loop in javascript, not perl
>   // ..etc
>   for(i=0 ; i<size ; i++) {
>     imagearray[i] = <% $masonarray[ WHAT ] %>
>   }
> </script>

You can't do it like that, Mason generates the JavaScript, the
JavaScript isn't executed while Mason is running and visa versa.

What you want to do, is something like this:

 <script type="text/javascript">
   var size = <% scalar @sortedfiles %>;
   var imagearray = new Array(size);
   // do the for loop in javascript, not perl
   // ..etc
% for(my $i = 0; $i < scalar @sortedfiles; i++) {
   imagearray[<% $i %>] = <% $masonarray[$i] %>
% }
 </script>

Which will generat JavaScript that looks like this:

 <script type="text/javascript">
   var size = 3;
   var imagearray = new Array(size);
   // do the for loop in javascript, not perl
   // ..etc
   imagearray[0] = something
   imagearray[1] = somethingelse
   imagearray[2] = someotherthing
 </script>

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to