我需要從選擇選項下拉式表格中獲取價格以獲得金額輸入。我有jQuery將從下拉列表中選擇值,我知道我需要使用Ajax來做到這一點,我不確定Ajax的機制以及如何去做。我能得到幾個指針嗎?如何獲取Ajax更新金額輸入?
<select id="selectMembership" class="cat_dropdown " name="selectMembership">
<option type="text" value="5" selected="selected" id="amount-paypal" name="amount">5</option>
<option type="text" value="10" id="amount-paypal" name="amount">10</option>
<option type="text" value="20" id="amount-paypal" name="amount">20</option>
</select>
This input needs to receive the selected value
<input type="text" value="" id="amount-paypal" name="amount">
<script type="text/javascript">
$(document).ready(function(){
//choose which price to use from select form
$('select').on('change', function(){
$('#amount-paypal').val($(this).val());
});
});
</script>
需要AJAX爲我編輯:ID必須是唯一的! –
是的,你是對的,我也發現了這一點,感謝您的關注! – Grant