修改竞赛中搜索,搜索条件可以为空,且为空时搜出所有竞赛

This commit is contained in:
sw 2014-12-19 14:45:50 +08:00
parent c6be2317a7
commit d6d7331ec6
2 changed files with 31 additions and 4 deletions

View File

@ -46,7 +46,7 @@
<%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName();' %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10">
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="padding-top: 7px !important;">
<%= l(:label_search)%>
</a>
<br />

View File

@ -36,11 +36,38 @@
<strong><%= l(:label_user_location) %> : </strong>
</td>
<td rowspan="2" width="250px">
<script type="text/javascript">
function regexName()
{
var name = $.trim($("#name").val());
if(name.length == 0)
{
$("#contest_name_span").text("<%= l(:label_search_conditions_not_null) %>");
$("#contest_name_span").css('color','#ff0000');
$("#contest_name_span").focus();
return false;
}
else
{
$("#contest_name_span").text("");
return true;
}
}
function submitSerch()
{
if(regexName()){$("#contst_search_form").submit();}
}
</script>
<div class="project-search">
<%= form_tag({controller: 'contests', action: 'index'}, method: :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= form_tag({controller: 'contests', action: 'index'}, method: :get, :id => "contst_search_form") do %>
<%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => 'regexName();' %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="padding-top: 7px !important;">
<%= l(:label_search)%>
</a>
<span id="contest_name_span"></span>
<% end %>
</div>
</td>