L
L
Leopandro2016-06-28 22:02:19
JavaScript
Leopandro, 2016-06-28 22:02:19

Why does the dropdown field attribute get selected all the time?

I just replace the values ​​for the dropdownlist when the value of another field changes:

function replaceCarsDropDown()
{
  $.ajax({
    url : '$urlGetDrivers',
    type : 'post',
    data : {
      id : $('#panel_car_value_select2').val(),
      //order_id: $model->id
    },
    success : function(data){
      $('#panel-driver_id').empty();
      $('#panel-driver_id').append($(data).children());
    }
  })
}

Where $('#panel-driver_id') is the id of the dropdown sheet

The server returns the data like this:
$result = $car->getDrivers();
      $arr = [];
      if ($result)
      {
        foreach ($result as $key => $item)
        {
          $arr[$item['id']] = $item['name'].' '.$item['surname'];
        }
      }

      $return = Html::dropDownList('drop', null, $arr, [
        'prompt' => '-- Выберите --'
      ]);


Sample query result:
"
<select name=\"drop\">\n<option value=\"\">-- Выберите --</option>\n<option value=\"2\">asdf adf</option>\n</select>"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2016-06-29
@springimport

Maybe it has something to do with Yii validation, try turning it off.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question