OnClose无法正常运作

时间:2019-06-15 07:56:34

标签: javascript jsp

当通过JSP页面调用函数时,我在Javascript函数内部使用了Onclose函数

<html:text styleId="fromDate${rowCount}" styleClass="soa_chargesinput"  name="confDatalist" maxlength="12" onclick="singleDatePickerAdder(${rowCount})" readonly="true"  property="fromDate" /> in jsp i called singleDatePickerAdder function 

function singleDatePickerAdder(input){

    var todayDate = new Date();
    var monthPart = todayDate.getMonth();
    var datePart = todayDate.getDate();
    if (monthPart == 12) {
        monthPart = monthPart-1;
    }
    var twoDigitMonth = (monthPart < 9)? '0'+(monthPart+1) : (monthPart+1);  
    var twoDigitDay = (datePart < 10)? '0'+datePart : datePart;  
    var currentDate = twoDigitDay + "/" + twoDigitMonth + "/" + todayDate.getFullYear();
    $('#fromDate'+input).datepicker({
        format: 'dd/mm/yyyy', 
        defaultDate: currentDate, 
        changeMonth: true, 
        changeYear: true, 
        autoclose: true,
        numberOfMonths: 1,  
        onClose: function( selectedDate ) {
        var scheduleType = document.getElementById("scheduleType"+input).value;
        if(scheduleType == 1){
        document.getElementById("toDate"+input).disabled = true;
        document.getElementById("toDate"+input).value = document.getElementById("fromDate"+input).value
        }
        }
    }); 

这里onclose函数在添加新行时不起作用

scheduletype为1时,应该是date,但是它没有改变 在添加新行时,它会被正确调用

0 个答案:

没有答案