用戶使用jquery日期選擇器輸入日期,這是以mm/dd/yyyy格式顯示的,表單用於使用列查詢MySQL數據庫(CADNO )以整數格式記錄日期,例如-3987。在窗體上使用jquery日期選擇器將用戶輸入轉換爲整數日期
-3987是從05/09/2006(這是kepreported_date列的日期)計算出來的,這是因爲CADNO列計算從今天的日期到reported_date列的天數。
問題是,有沒有辦法在jQuery上創建一個公式,將用戶輸入的日期轉換爲MySQL服務器期望的格式?
<script>
$(函數(){
var dateFormat = "mm/dd/yy",
date_from = $("#date_from")
.datepicker({dateFormat: 'dd/mm/yy',
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 3
})
.on("change", function() {
date_to.datepicker("option", "minDate", getDate(this));
}),
date_to = $("#date_to").datepicker({dateFormat: 'dd/mm/yy',
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
numberOfMonths: 3
})
.on("change", function() {
date_from.datepicker("option", "maxDate", getDate(this));
});
function getDate(element) {
var date;
try {
date = $.datepicker.parseDate(dateFormat, element.value);
} catch(error) {
date = null;
}
return date;
}
});
ts=ts&"<form method='post' action='search_prep.asp'>"
ts=ts&"<tr><td>Search</td>"
ts=ts&"<td><select size='1' name='search_field' id='search_field'>"
for p=0 to colrows
\t ts=ts&"<option value='"&cols(0,p)&"'>"&cols(1,p)&"</option>"
next
ts=ts&"</select></td></tr>"
ts=ts&"<tr><td>For</td>"
ts=ts&"<td><input type='text' size='12' name='search_text' id='search_text' >"
ts=ts&" <input type='radio' name='andor' value='and'>AND"
ts=ts&" <input type='radio' name='andor' value='or' "&chkandor&">OR"
ts=ts&" <input type='text' size='12' name='search_text2' id='search_text2'></td>"
ts=ts&"<td><input type='checkbox' name='search2' value='yes' "&chk2stage&" >2 Stage query required</td>"
ts=ts&"<td>"
ts=ts&"<input type='radio' name='repclr' value='radno' "&chkreprep&">Reports"
ts=ts&" <input type='radio' name='repclr' value='cadno' "&chkrepclr&" >Clears "
'ts=ts&" range between <select size='1' name ='date_from' id='date_from'>" -commented for datepicker
ts=ts&"</tr> "
ts=ts&"</td>"
ts=ts& "<tr><td>Date Between</td> <td><input type='text' style='text-align:center;' size='19' name='date_from' id='date_from'>"
'for i = mindate to maxdate-commented for datepicker
\t 'ts=ts&"<option value="&i&">"&date() + i&"</option>"-commented for datepicker
'next-commented for datepicker
'ts=ts&"</select>"-commented for datepicker
'ts=ts&"and<select size='1' name ='date_to' id='date_to'>"
'for i = maxdate to mindate step -1
' \t ts=ts&"<option value="&i&">"&date() + i&"</option>"
'next
'ts=ts&"</select>"
ts=ts& " And <input type='text' style='text-align:center;' size='19' name='date_to' id='date_to'>"
ts=ts&"</td>"
ts=ts&"<td> <input type='submit' value='Go'></td>"
ts=ts&"</tr> "
ts=ts&"<input type='hidden' name='nocom' value='"&nocom&"'>"
ts=ts&"<input type='hidden' name='current_tech' value='"¤t_tech&"'>"
ts=ts&"<input type='hidden' name='current_status' value='"¤t_status&"'>"
ts=ts&"<input type='hidden' name='status' value='"&status&"'>"
ts=ts&"</form></table></div>"
請輸入您的正確密碼 –
什麼是ts = ts&?? – Strawberry