0

如何在使用函数时将日期选择器的值保留在文本区域中?

前任:

if($currentSelectionClass == "rowStartDate"){
    $('<input id="selectDateStart" type="text" />')
        .attr('name', 'editStartDate')
        .addClass('editStartDate')
        .appendTo(this)
        .datepicker({onSelect: startDateSubmit()});
    }

以及如何将 datepicker 值发送到我的函数?

功能代码:

function startDateSubmit(){
            $selectDateStart = $('#selectDateStart').val();
            $.ajax({ 
                url: '/ajax/training-update.php',
                data: {action: $selectDateStart},
                type: 'POST',
                success: function(output) {
                    alert(output);
                    }
            });
        }
4

1 回答 1

2
  1. 您需要指定对函数的引用,而不是调用该函数

    .datepicker({onSelect: startDateSubmit});
    
  2. 您需要在函数声明中添加参数

    function startDateSubmit(selectedDate) {
    
于 2012-09-07T00:08:32.827 回答