I'm trying to auto submit a form when the page loads using the jQuery code below:
$(document).ready(function(){
$("#finds_expense").submit();
});
The form submission requires the parameters as JS. When I submit the form manually, it works perfectly, but when I use jQuery's (document).ready, somehow the parameters are passed as HTML, not JS. I appreciate any help on this. Had been stucked with this problem for quite some time. TQ.
Below is the code for finds_expense:
<div id="month-lookup">
<%= form_tag search_expense_path, remote: true, method: :get, id: "finds_expense" do %>
<div class="form-group row no-padding text-center col-md-8">
<div class="col-md-4">
<%= text_field_tag :month, params[:month],
placeholder: "month",
autofocus: true,
class: "form-control search-box input-lg" %>
</div>
<div class="col-md-4">
<%= text_field_tag :year, params[:year],
placeholder: "year",
autofocus: true,
class: "form-control search-box input-lg" %>
</div>
<div class="col-md-2">
<%= button_tag(type: :submit, class: "btn btn-lg btn-success", id: "submit_expense") do %>
<i class="fa fa-search"></i> Send
<% end %>
</div>
</div>
<%end%>
remote: truein your form ?<%= form_tag XXXX, remote: true%>finds_expenseform code?