我想获取vuejs2内部select选项的当前值。
我有这个laravel刀片代码:
<select class='form-control units' @change='units' name='items_quantity_unit_id[]' required>
@foreach($units as $unit)
<option class='form-control' value='{{$unit["id"]}}'>{{$unit['unit_name']}}</option>
@endforeach
</select>
我有这个vuejs2代码
units:function(){
var unit_id = $(this).val();
console.log(unit_id);
}
现在,当我更改选择选项时,出现此错误:
ncaught TypeError: Cannot read property 'toLowerCase' of undefined
所以当我更改vuejs2中的选项时如何获得值。
谢谢
答案 0 :(得分:1)
$sql = "SELECT event_name FROM dbs_events where event_id = ?";
// Prepare the SQL statement, bind the parameters and then execute
$stmt = $conn->prepare($sql);
$stmt->bind_param('i', $event_id);
$stmt->execute();
// Fetch the results now
$result = $stmt->get_result();
// Close the statement
$stmt->close();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc(); // I am not sure what you need this for
// Preparing Update query statement; binding params and execute
$sql = "UPDATE dbs_events
SET event_name = ?,
sport_id = ?
WHERE event_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('sii', $event_name, $sport_id, $event_id);
$stmt->execute();
$stmt->close();
} else {
// Preparing Insert query statement; binding params and execute
$sql = "INSERT INTO dbs_events
(event_id, event_name, sport_id, event_sort_order)
VALUES
(?,?,?,?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param('isii', $event_id, $event_name, $sport_id, $event_sort_order);
$stmt->execute();
$stmt->close();
}
但是我建议使用v-model,请看Form Input Bindings指南。