【发布时间】:2016-10-22 14:01:28
【问题描述】:
如何在 javascript 中更改视图的变量值。我的意思是当我从下拉表中选择四月时,将只显示四月的数据,当前表数据将消失并刷新。我该怎么做?帮我
我的 JS
:javascript
var updateMonth = function(){
var month_id = $("#select_other_month").val();
console.log(month_id)
}
这是我的选择标签(下拉菜单)
%select{:name => "options", :id=>"select_other_month",:onchange=>"updateMonth()"}
%option.placeholder{:disabled => "", :selected => "", :value => ""} see other months
%option{:value => "0"} this month
-a=@this_month - 1.month
%option{:value => "5"}=a.strftime('%Y-%m')
-b=@this_month - 2.month
%option{:value => "4"}=b.strftime('%Y-%m')
-c=@this_month - 3.month
%option{:value => "3"}=c.strftime('%Y-%m')
-d=@this_month - 4.month
%option{:value => "2"}=d.strftime('%Y-%m')
-e=@this_month - 5.month
%option{:value => "1"}=e.strftime('%Y-%m')
我的桌子是这样的
.table{:id=>"time_table"}
%table{:border=>"1"}
%thead
%tr
%th No
%th Name
-(@xmonth.at_beginning_of_month..@xmonth.at_end_of_month).each do |day|
-if (day.saturday? || day.sunday?)==false
%th=day.strftime("%d")
%th Total days
%th Total time
我想从 JS 更改我的 @xmonth 变量
注意:@this_month = Date.today
【问题讨论】:
-
您想从服务器获取新数据并进行填充?
-
是的,我是。我现在该怎么办?
标签: javascript jquery ruby-on-rails haml