我已經檢出了這個thread和this one但它並沒有真正幫助我。未捕獲ReferenceError:functionName未定義
我有一個ASP:複選框控件如下所示。
<asp:CheckBox ID="chbArchived" runat="server" Checked='<%# Bind("archived") %>' OnClick=changeExpirationDate() />
我的JavaScript是如下:
<script type="text/javascript">
$(document).ready(function() {
//alert("got here");
$('.insDateTime').datetimepicker({
ampm: true
});
changeExpirationDate(){
var currentDate = new Date;
var futureDateTime = (currentDate.getMonth() + 4) + '/' + currentDate.getDate() + '/' + currentDate.getFullYear() + ' ' + formatAMPM(currentDate);
var expiredDateTime = (currentDate.getMonth() + 1) + '/' + currentDate.getDate() + '/' + currentDate.getFullYear() + ' ' + formatAMPM(currentDate);
var archivedCheckbox = document.getElementById('cphContent_fmvNewsEventList_chbArchived').checked;
if(archivedCheckbox == true)
{
document.getElementById('cphContent_fmvNewsEventList_txtExpirationDate').value = expiredDateTime;
}
else{
document.getElementById('cphContent_fmvNewsEventList_txtExpirationDate').value = futureDateTime;
}
};
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return strTime;
};
});
</script>
的問題是我一直得到這個JavaScript錯誤「未捕獲的ReferenceError:changeExpirationDate沒有定義」當我點擊複選框。任何建議/幫助非常感謝。
謝謝!這是一個非常愚蠢的錯誤 - 完全忘了。 – 2myCharlie