如何在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
是的,我是。我現在應該怎麼做? –