如何在javascript中更改视图的变量值。我的意思是,当我从下拉表中选择四月份时,只会显示四月份的数据,而当前表格数据会消失并刷新。我该怎么做?帮我
我的JS如何在js of rails中更改视图的可视化
: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
[email protected]_month - 1.month
%option{:value => "5"}=a.strftime('%Y-%m')
[email protected]_month - 2.month
%option{:value => "4"}=b.strftime('%Y-%m')
[email protected]_month - 3.month
%option{:value => "3"}=c.strftime('%Y-%m')
[email protected]_month - 4.month
%option{:value => "2"}=d.strftime('%Y-%m')
[email protected]_month - 5.month
%option{:value => "1"}=e.strftime('%Y-%m')
和我的表看起来像这样
.table{:id=>"time_table"}
%table{:border=>"1"}
%thead
%tr
%th No
%th Name
-(@[email protected]_end_of_month).each do |day|
-if (day.saturday? || day.sunday?)==false
%th=day.strftime("%d")
%th Total days
%th Total time
我想改变我的@xmonth从vairable JS
注意:@this_month = Date.today
你想从服务器获取新的数据并填充? – Kumar
是的,我是。我现在应该怎么做? –