1 回答
TA贡献1809条经验 获得超8个赞
您可以这样:
<form method="post" class="cart" action="Booking_form.php">
<div class="quantity btn-quantity pull-left m-r10">
<select name="vechile_type" class="form-control veh_type">
<option value="">Select Vechile</option>
<option value="Hatchback" data-price="1500">Hatchback</option>
<option value="Sedan" data-price="1000">Sedan</option>
</select>
<input type="hidden" name="price" class="hidd_price">
</div>
<button class="btn btn-primary site-button pull-left"><i class="fa"></i> Book Now</button>
<script>
$(document).ready(function () {
$('body').on('change', '.veh_type', function(e){
if($(this).val() != ''){
$('.hidd_price').val($(this).find('option:selected').attr("data-price"));
}else{
$('.hidd_price').val('');
}
});
});
</script>
- 1 回答
- 0 关注
- 143 浏览
添加回答
举报