<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" style="width:145px">考勤日期:</td>
<td style="width:609.5px"><input id="<%= day %>" name="<%= day %>" type="date" value="<%= day%>" ></td>
<td class="eheader" style="width:145px">考勤班组:</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" style="width:145px">考勤日期:</td>
<td style="width:609.5px"><input id="<%= day %>" name="<%= day %>" type="date" value="<%= day%>" ></td>
<td class="eheader" style="width:145px">考勤班组:</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是循环的变量。
打开App,阅读手记