ruby select结合javaScript显示影藏div防刷新哦

  <script type="text/javascript" >
  function switch_question_content_by_question_type(question_type){
    $('.question_content').hide()
    if(question_type == 'question_type_1'){
      div_to_show ='question_content_of_question_with_numbers'
    }else if (question_type == 'question_type_2'){
      div_to_show ='question_content_of_question_with_options'
    }else{
      div_to_show ='question_content_of_question_with_text'
    }
    $('#'+div_to_show).show()
  }
  </script>




<select size="1" name="category_field_type" id="category_field_type" onChange="javascript:switch_question_content_by_question_type('question_type_'+this.value)")">  
      <option value="1" >数值</option> 
      <option value="2" >分类</option> 
      <option value="3" >文本</option>
</select> 


<div class="question_content" id="question_content_of_question_with_numbers" style="display:block">
    <h>单位</h></br>
    <input type="text" value="<%= @category_id_project.unit %>" name="category[unit]" placeholder="请输入数值单位">
  </div> 
  
  <!-------------------------------选择分类-------------------------------------->
  <div class="question_content" id="question_content_of_question_with_options" style="display:none">  
    <br><input type="text" value="<%= @answer_list.answer1 %>" name="answer_list[answer1]" placeholder="请输入分类名"></br>
    <br><input type="text" value="<%= @answer_list.answer2 %>" name="answer_list[answer2]" placeholder="请输入分类名"></br>
    <br><input type="text" value="<%= @answer_list.answer3 %>" name="answer_list[answer3]" placeholder="请输入分类名"></br>
    <br><input type="text" value="<%= @answer_list.answer4 %>" name="answer_list[answer4]" placeholder="请输入分类名"></br>
    <br><input type="text" value="<%= @answer_list.answer5 %>" name="answer_list[answer5]" placeholder="请输入分类名"></br>
  </div>


  <!-------------------------------选择文本-------------------------------------->
  <div class="question_content" id="question_content_of_question_with_text" style="display:none">
  </div> 












<script>
jQuery(document).ready(function(){
  switch_question_content_by_question_type('question_type_'+ $('#category_field_type').val())  
})
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值