JQuery 更改 Select 括号值的问题
Issue with JQuery changing Select Bracket value
在我的网站上,用户 select 是一个人,当创建 selection 时,它会在下面填充关于该患者的人口统计数据,但为用户提供了更改每个人口统计值的选项.我有一个 html select 的 "Prep RN" 语句,它是在加载表单时从 table RNs 填充的,但是当我 select 一个病人时,我无法将 select 更改为存储在数据库中并包含在列表中的 RN:
$.ajax({
url: 'php/pullselectedpatient.php',
type: 'POST',
dataType: 'json',
cache: false,
data: {Patient_UID: tempPatient_UID},
success: function(data) {
if (data.Prep_RN == 'Unassigned') {
//if unassigned, set option to unassigned
$('#selectpreprn').val('Unassigned');
} else {
//if assigned, change to selected RN
$('#selectpreprn').val(data.Prep_RN);
},
error: function() {
alert("ajax call failed.");
}
});
此代码成功填充了选项列表,但如果它是问题的一部分,请看这里:
<label for='selectpreprn'>Prep RN: </label>
<select id="selectpreprn">
<option value="empty"></option>
<?php
require('php/pullrns.php');
//loop and add the patients to the drop down list
foreach($result_rns->fetch_all(MYSQLI_ASSOC) as $row) {
echo "<option value='", $row['RN_UID'], "'>", $row['RN_UID'], "</option>";
}
?>
</select>
结果是 select 填充了 'blank'、'Unassigned',然后是 3 个名称可供选择。
另外,这是我第一次在这个网站上发帖(非常有帮助),所以我希望我提供了一切。我花了至少 3 个小时尝试不同的东西来完成这项工作。
重申一下,问题是当患者 selected 时,它没有 select select 标签中的选项。它只是保持空白。
此代码按预期工作,问题出在我页面的下方,我无意中覆盖了此选择器。我复制并粘贴了类似的代码,这让我遇到了麻烦 =(
在我的网站上,用户 select 是一个人,当创建 selection 时,它会在下面填充关于该患者的人口统计数据,但为用户提供了更改每个人口统计值的选项.我有一个 html select 的 "Prep RN" 语句,它是在加载表单时从 table RNs 填充的,但是当我 select 一个病人时,我无法将 select 更改为存储在数据库中并包含在列表中的 RN:
$.ajax({
url: 'php/pullselectedpatient.php',
type: 'POST',
dataType: 'json',
cache: false,
data: {Patient_UID: tempPatient_UID},
success: function(data) {
if (data.Prep_RN == 'Unassigned') {
//if unassigned, set option to unassigned
$('#selectpreprn').val('Unassigned');
} else {
//if assigned, change to selected RN
$('#selectpreprn').val(data.Prep_RN);
},
error: function() {
alert("ajax call failed.");
}
});
此代码成功填充了选项列表,但如果它是问题的一部分,请看这里:
<label for='selectpreprn'>Prep RN: </label>
<select id="selectpreprn">
<option value="empty"></option>
<?php
require('php/pullrns.php');
//loop and add the patients to the drop down list
foreach($result_rns->fetch_all(MYSQLI_ASSOC) as $row) {
echo "<option value='", $row['RN_UID'], "'>", $row['RN_UID'], "</option>";
}
?>
</select>
结果是 select 填充了 'blank'、'Unassigned',然后是 3 个名称可供选择。
另外,这是我第一次在这个网站上发帖(非常有帮助),所以我希望我提供了一切。我花了至少 3 个小时尝试不同的东西来完成这项工作。
重申一下,问题是当患者 selected 时,它没有 select select 标签中的选项。它只是保持空白。
此代码按预期工作,问题出在我页面的下方,我无意中覆盖了此选择器。我复制并粘贴了类似的代码,这让我遇到了麻烦 =(