Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I change a background image depending on what results are being displayed?
    text
    copied!<p>I have a table of venues and areas where each venue belongs to an area and an area has many venues.</p> <p>The venues index page is displaying all the venue records as partials and I have a set of checkboxes to filter the venues shown by what area they are in.</p> <p>I also have a div (map_container) which shows a map .png image of all the areas on the right of the screen. </p> <p><b>venue index.html.erb</b></p> <pre><code>&lt;div class="map_container"&gt; &lt;/div&gt; &lt;div class="filter_options_container"&gt; &lt;form class="form"&gt; &lt;fieldset class="filter_form_fieldset areas"&gt; &lt;% Area.all.each do |a| %&gt; &lt;%= check_box_tag 'areas[]', a.id, false, :id =&gt; "area-#{a.id}" %&gt; &lt;label for="area-&lt;%= a.id %&gt;"&gt;&lt;p1&gt;&lt;%= a.name %&gt;&lt;/p1&gt;&lt;/label&gt; &lt;% end %&gt; &lt;/fieldset&gt; &lt;div class="form_filter_button"&gt; &lt;p2&gt;&lt;input type="submit" value="Filter"/&gt;&lt;/p2&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="venue_partials_container"&gt; &lt;%= render :partial =&gt; 'venue', :collection =&gt; @venues %&gt; &lt;div class="clearall"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="clearall"&gt;&lt;/div&gt; </code></pre> <p>How would it be possible to check whether all the venues being displayed have the same area_id and if they do display a different map image in the map div? So if all venues have area_id of 1 then display map1.png or if they all have an area_id of 2 then display map2.png etc.</p> <p>Thanks for any help, its much appreciated!</p>
 

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