jQuery:如何从PHP / CakePHP的输入字段中获取输入值?

时间:2015-12-30 17:20:58

标签: php jquery html cakephp

我尝试过几件事情仍然无法正确返回价值。我正在使用CakePHP 2.0v。

这是我的第一个输入字段

echo $this->Form->input('semesterFrom', array(
  'options' => $semesterOptions,
  'empty' => 'Select',
  'label' => false,
  'class' => 'form-control', 
  'name' => 'data[student][semester]'));

这是我的第二个输入/选择字段

echo $this->Form->year('class_yearFrom', date('Y'), 2030, array(
  'empty' => __('Select Year'),
  'class' => 'form-control year',
  'name' => 'data[student][class_year]'));

我尝试了以下内容。

var attendanceSemesterValue = app.myGoalForm().find('#StudentSemesterFrom').val(); //also variations of :selected and .text()/.val()
var attendanceYearValue = app.myGoalForm().find('#StudentClassYearFromYear :selected').val();

if (attendanceSemesterValue === "Select" && attendanceYearValue === "Select Year") { 
       var wantedYearValue; 
       wantedYearValue = 0;
      } else {
            wantedYearValue = {
                'semesterFrom': app.myGoalForm().find('#StudentSemesterFrom :selected').val(),
                'yearFrom': app.myGoalForm().find('#StudentClassYearFromYear :selected').val(),
            };
            var studentRangeValue = app.myGoalForm().find('#StudentRange').is(':checked');

            if (studentRangeValue) {
                $.extend(wantedYearValue, {
                    'semesterTo': app.myGoalForm().find('#StudentSemesterTo :selected').text(),
                    'yearTo': app.myGoalForm().find('#StudentClassYearToYear :selected').text(),
                });

            }
        }

0 个答案:

没有答案