I am a new user of the prototype framework and am having problems
getting examples that address the type of issues I am having.
I am writing a random phrase generator by am using the Ajax.request to
read a static XML file. I want to use the Ajax.request result to query
according to a couple of factors. An example of the XML file
structured as follows:
<phrases>
<mood id="happy">
<phrase id="30">This happy phrase should be shown on random
numbers between 1 and 30.</phrase>
<phrase id="60">This happy phrase should be shown on random
numbers between 31 and 60.</phrase>
<phrase id="80">This happy phrase should be shown on random
numbers between 61 and 80.</phrase>
<phrase id="100">This happy phrase should be shown on random
numbers between 81 and 100.</phrase>
</mood>
<mood id="sad">
<phrase id="30">This sad phrase should be shown on random
numbers between 1 and 30.</phrase>
<phrase id="60">This sad phrase should be shown on random
numbers between 31 and 60.</phrase>
<phrase id="80">This sad phrase should be shown on random
numbers between 61 and 80.</phrase>
<phrase id="100">This sad phrase should be shown on random
numbers between 81 and 100.</phrase>
</mood>
</phrases>
On the HTML page I have a form with a select box to select the moods
(happy, sad, etc.) and a button to execute a Javascript function that
generates a random number and display the correct phrase.
My thinking is that I would create an Enumerable object that I would
load the XML into. Then I could use find() and/or other Enumerable
methods to locate the correct mood node and iterate to the phrase node
with the id that is less than or equal to the random number.
I can't seem to find enough documentation on prototype's Enumerable
object to construct my phrase object. Everything I've tried has not
worked so far. Anyone have any suggestions?
Thanks a million!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---