<script src="__TMPL__Public/layui/laytpl.js" charset="utf-8"></script>
<script id="demo" type="text/html">
{{# for(var name in d){ }}
<option al="{{d[name]}}" value="{{name}}">{{name}} 天</option>
{{# } }}
</script>
<script>
var data = <?php echo json_encode($data);?>;
function check(){
var checkValue = $('#order_num').find("option:selected").val();
var pd = eval(data[checkValue].price_detail);
var gettpl = document.getElementById('demo').innerHTML;
laytpl(gettpl).render(pd, function(html){
document.getElementById('period').innerHTML = html;
});
}
function al(){
var al = $('#period').find("option:selected").attr("al");
$('#price').val(al);
}
check();
al();
$('#order_num').change(function(){
checkValue = $(this).val();
pd = eval(data[checkValue].price_detail);
var gettpl = document.getElementById('demo').innerHTML;
laytpl(gettpl).render(pd, function(html){
document.getElementById('period').innerHTML = html;
});
al();
});
$("#period").bind("change",function(){
var al = $(this).find("option:selected").attr("al");
$('#price').val(al);
});
</script>
价格的三级联动
发表于

发表回复