-2
是否可以更改所選數據的值?更改值datepicker
因此,當他們選擇10月份時,它會提交value =「10」,但它必須更改爲value =「9」。
這可能嗎?
我使用下面的代碼:
<script type='text/javascript'>
$(window).load(function(){
$(".date_year").datepicker({
showOn: 'button',
//buttonImage: "calendar_icon.png",
buttonText: 'Cal',
buttonImageOnly: false,
showAnim: 'fadeIn',
dateFormat: 'dd/mm/yy',
onClose: function (dateText, picker) {
dateArr = dateText.split('/');
$(this).siblings('.date_month').val(dateArr[1]);
$(this).siblings('.date_day').val(dateArr[0]);
$(this).val(dateArr[2]);
}
});
});>
</script>
而我的HTML是:
<div class="date-picker">
<label for="preferredDate">Arrival</label>
<input type="text" class="date_day" name="day_a" />/
<input type="text" class="date_month" name="month_a" />/
<input type="text" class="date_year" name="year_a" />
</div>
<div class="date-picker">
<label for="preferredDate">Departure</label>
<input type="text" class="date_day" name="day_d" />/
<input type="text" class="date_month" name="month_d" />/
<input type="text" class="date_year" name="year_d"/>
</div>
感謝斯蒂芬爲您的答覆,這樣做的工作,但問題是,更改後的值現在可以在輸入字段中看到。用戶可能看不到更改的值,只有將正確的值發送到其他服務器纔是重要的。這可能嗎? – steven
然後這不是日期選擇器可以做的事情。所有的日期選擇器都會填寫一個字段,將字段提交給服務器不是腳本的一部分。您必須製作一個腳本,在發送之前更改提交字段的值。 –