我的问题是,如果我在选择ABS时选择像ABS中的某些内容,我怎么能有一个文本框显示输入的其他信息。我现在所拥有的是不工作......非常感谢任何帮助!
这是我的app.js
$(document).ready(function(){
$('#indirect_id').change(function() {
var indirect_id = $(this).val();
if(indirect_id == 'ABS'){
$('#sick_comment').show();
}
else{
$('#sick_comment').hide();
}
});
这是我的观点
.row-fluid
=simple_form_for @entry, :url => url_for(:controller => 'entry', :action => 'create'), :method => :post do |f|
%table.table.table-bordered.table-striped{:style => 'table-layout:fixed; width:100% !important;'}
%th.lt Indirect Code:
%td.lt= f.input_field :indirect_id, :as => :select, :label => false, :collection => ['PD', 'VAC', 'ABS'], :id => 'indirect_id', :input_html => {:value => ''}
%th.lt Optional Comment
%td.lt= f.text_field :sick_day, :label => false, :id => 'sick_comment', :input_html => {:value => ''}
%table.table.table-bordered.table-striped{:style => 'table-layout:fixed; width:100% !important;'}
= f.button :submit, "Submit", :class => 'btn btn-primary', :style => 'margin-left:50px;'
答案 0 :(得分:2)
如果这是app.js的全文,那么您缺少一个结束括号和括号:
$(document).ready(function(){
$('#indirect_id').change(function() {
var indirect_id = $(this).val();
if(indirect_id == 'ABS'){
$('#sick_comment').show();
}
else{
$('#sick_comment').hide();
}
});
});