$().ready(function(){
$(‘#type‘).change(function(){
resetType()
});
resetType();
resetResult();
$(‘#question‘).change(function(){
resetResult();
});
});
function resetType() {
var type = $(‘#type‘).val();
if(type==‘1‘){
$(‘#result‘).hide();
$(‘#question‘).show();
}else{
$(‘#question‘).show();
$(‘#result‘).show();
}
}
function resetResult(){
var url = ‘{:U("sum/ajaxGetResults")}‘;
var type = $(‘#type‘).val();
if(type!=1){
var question_id = $(‘#question1‘).val();
$.ajax({
url:url,
data:{‘question_id‘:question_id},
type:‘post‘,
dataType:‘json‘,
success:function(data){
if(data.status){
$(‘#result1‘).empty();
$("#result1").append("<option value=‘1‘>"+data.option1+"</option>");
$("#result1").append("<option value=‘2‘>"+data.option2+"</option>");
//alert(data.option1);
}else{
alert(data.message);
}
},
});
}
}
<div class="tableList" style="padding: 10px 30px;"> <form name="data_search" method="post"> <span> <select name="type" id="type"> <option value="1">按数据基本情况统计</option> <option value="2">按称号统计</option> <option value="3">按职位统计</option> <option value="4">按车系统计</option> </select> </span> <span id="question"> 问题<select name="question" id="question1"> <volist name="questions" id="question"> <option value="{$question.id}">{$question.content}</option> </volist> </select> </span> <span id="result" style="display:none;"> 结果<select name="result" id="result1" > <option value="1">{$questions[0].option1}</option> <option value="2">{$questions[0].option2}</option> </select> </span> <input type="button" id="search_btn" name="search_btn" value="统计"/> </form> </div>