I have checked out this thread and this one but it didn't really help me.
I have a ASP:CheckBox control shown below.
<asp:CheckBox ID="chbArchived" runat="server" Checked='<%# Bind("archived") %>' OnClick=changeExpirationDate() />
My JavaScript are follows:
<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>
The problem is I kept getting this JavaScript error "Uncaught ReferenceError: changeExpirationDate is not defined" when I clicked on the checkbox. Any suggestion/help is much appreciated.