郭月翔
2019-01-23 10:58:44浏览 2972
<table width="100%" align="center" cellpadding="0" cellspacing="0" class="table" id="date_table">
<% @mplan.each do |day| %>
<% if day.saturday? || day.sunday? %>
<tr id="w<%= day %>" class="weekend">
<td class="eheader" >考勤日期:</td>
<td ><input id="<%= day %>" name="<%= day %>" type="date" value="<%= day%>" ></td>
<td class="eheader" >考勤班组:</td>
<td ><%= select_tag "shift#{day}" ,options_from_collection_for_select(@shifts,"id","shift"),:class => "text_input shift",:id =>"shift"+day.to_s %>
</td>
</tr>
<% else %>
<tr id="r<%= day %>">
<td class="eheader" >考勤日期:</td>
<td ><input id="<%= day %>" name="<%= day %>" type="date" value="<%= day%>" ></td>
<td class="eheader" >考勤班组:</td>
<td ><%= select_tag "shift#{day}",options_from_collection_for_select(@shifts,"id","shift"),:class => "text_input shift",:id =>"shift"+day.to_s %>
</td>
</tr>
<% end %>
<%end%>
</table>
关键代码 select_tag "shift#{day}" 其中day是循环的变量。