Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks as if you need a selector:</p> <pre><code>&lt;th id="&lt;%= "money_" + @counter.to_s %&gt;"&gt; &lt;label for="&lt;%= "money_" + @counter.to_s %&gt;"&gt; &lt;%= f.select(:money, 1..10, :selected =&gt; p.money)%&gt; &lt;/label&gt; &lt;/th&gt; </code></pre> <p>Now you've given Prototype the ability to search and find the correct element (the select with the value you're looking for), which you pass to the $() function to call getValue():</p> <pre><code>function change_people() { // Note the "#" on #money_1, which is an ID selector // the space " " between is a descendant element selector money1 = $($$('#money_1 select')).getValue(); if (money1 == 10) { // do stuff } else { // do other stuff } } </code></pre> <p>If you're looking to iterate over all of the money select values in the table, you would instead want to use a class; you are only allowed to have one element per ID, but a class by rule is grouped by attribute. The difference would be:</p> <pre><code>&lt;th class="money_select"&gt; &lt;label for="&lt;%= "money_" + @counter.to_s %&gt;"&gt; &lt;%= f.select(:money, 1..10, :selected =&gt; p.money)%&gt; &lt;/label&gt; &lt;/th&gt; </code></pre> <p>And then in your javascript:</p> <pre><code>function change_people() { // Note the "." on .money_1, which is a class selector // the space " " between is a descendant element selector $$('.money_select select').each(function(element){ if ($(element).getValue() == 10) { // do stuff } else { // do other stuff } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload