Ruby on rails with JQuery passing from div to div

In one html page I have the first div

    <select class="margin-bottom-20" id="event_title" name="event_title" style="width: 150px;">
        <option value="" selected><%= "Select a Title"%></option>            
        <% @all_events_title.each do |t| %>
            <option value="<%= t %>"><%= t %></option> 
        <% end %>             


Second div,

    @events_all.each do |e|
        if e["title"] == **document.getElementById("event_title").value;**
            @all_events_by_title << e


how can i get the value event_title

for the second div dynamically?

Thanks in advance!


source to share

1 answer

Create a script tag in the same html to add a div with javascript

<script type="text/javascript">
  $(function () {
    var $divEl = $("<div>");
    var eventTitle = document.getElementById("event_title").value;
    <% @events_all.each do |e| %>
      var title = <%= e["title"] %>;
      if (eventTitle = title) {
        // not sure what you are trying to do here...
        <% @all_events_by_title << e %>
      var $spanEl = $("<span>").html(<%= e["sport"] %>);
    <% end %>




All Articles