On 27/12/2007, Daanoz <[EMAIL PROTECTED]> wrote:
>
> today i was working some javascript when my array's didn't behave as
> expected, so after some research i found prototype was the cause...
> try my test to see what i mean, so my question is, how can i loop
> associative array (so i can get all keys for the array) without
> prototype giving me all functions?
>
> Test HTML:
>
> *************************************************************************************
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"; lang="nl" xml:lang="nl">
> <head>
> <title>Test HTML</title>
> <meta name="description" content="" />
> <meta name="keywords" content="" />
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <script src="prototype.js" type="text/javascript"></script>  <!--
> Prototype JavaScript framework, version 1.6.0 -->
> <script type="text/javascript">
>
>         function CTest()
>         {
>                 this.aTest = new Array();
>                 this.aTest["key1"] = "val1";
>         }
>
>         CTest.prototype.printArray = function()
>         {
>                 var PrintOut = "<table>";
>
>                 for(x in this.aTest) {
>                         PrintOut += "<tr><td>" + x;
>                         PrintOut += "</td><td>";
>                         PrintOut += this.aTest[x];
>                         PrintOut += "</td></tr>";
>                 }
>
>                 PrintOut += "</table>";
>                 document.getElementById('result').innerHTML = PrintOut;
>         }
>
>         var Test = new CTest();
> </script>
> </head>
> <body>
> <div onclick="Test.printArray()">clickme</div>
> <div id="result"></div>
> </body>
> </html>
>
> >
>

Replace this line ...

  this.aTest["key1"] = "val1";

with this line ...

  this.aTest = { "key1" : "val1"};

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to