问题遇到的现象和发生背景
layui select框里回显数据库的值失败
问题相关代码,请勿粘贴截图
<title>欢迎页面-X-admin2.2</title><body>
<div class="layui-fluid">
<div class="layui-row">
<form id = "form" class="layui-form">
<div class="layui-form-item">
<label for="userCode" class="layui-form-label">
<span class="x-red">*</span>用户名</label>
<div class="layui-input-inline">
<input type="text" id="userCode" name="userCode" required="" readonly="readonly" autocomplete="off" class="layui-input"></div>
<div class="layui-form-mid layui-word-aux">
<span class="x-red">*</span>将会成为您唯一的登入名!不可修改!!!</div></div>
<div class="layui-form-item">
<label for="userName" class="layui-form-label">
<span class="x-red">*</span>用户姓名</label>
<div class="layui-input-inline">
<input type="text" id="userName" required="" autocomplete="off" class="layui-input"></div>
<div class="layui-form-mid layui-word-aux">
<span class="x-red">*</span>请填写您的真实性名</div></div>
<div class="layui-form-item">
<label for="userSex" class="layui-form-label">
<span class="x-red">*</span>用户性别</label>
<div class="layui-input-inline">
<select name="userSex" id="userSex" >
<option value="1" >男</option>
<option value="2" >女</option>
</select>
</div>
<div class="layui-form-mid layui-word-aux">
</div></div>
<div class="layui-form-item">
<label for="userBirthday" class="layui-form-label">
<span class="x-red">*</span>出生日期</label>
<div class="layui-input-inline">
<input type="text" Class="Wdate" id="userBirthday" name="birthday" autocomplete="off"
style="width: 185px;height: 25px;" onclick="WdatePicker();"></div>
<div class="layui-form-mid layui-word-aux">
<span class="x-red">*</span>请重新选择您的出生日期
</div></div>
<div class="layui-form-item">
<label for="userPhone" class="layui-form-label">
<span class="x-red">*</span>联系方式</label>
<div class="layui-input-inline">
<input type="text" id="userPhone" autocomplete="off" class="layui-input"></div>
<div class="layui-form-mid layui-word-aux">
</div></div>
<div class="layui-form-item">
<label for="userAddress" class="layui-form-label">
<span class="x-red">*</span>家庭地址</label>
<div class="layui-input-inline">
<textarea style="width: 190px;height: 100px;" id="userAddress" required="" autocomplete="off" class="layui-input"></textarea>
</div>
<div class="layui-form-mid layui-word-aux">
</div></div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<input type="button" id="save" class="layui-btn" lay-filter="edit" lay-submit="" value="修改"></div>
</form>
</div>
</div>
<script>
$(function () {
var userCode = getParam("userCode");
$.ajax({
url:"/SSM_hospital/user/queryUserByUserCode",
type:'post',
data:{"userCode":userCode},
dataType:'json',
success:function (d) {
//解析数据
$("#userCode").val(d.userCode);
$("#userName").val(d.userName);
/*$("#userSex").val(d.userSex);*/
//数据回显性别时出现问题,无法获取原始性别
$("#userBirthday").val(d.userBirthday);
$("#userPhone").val(d.userPhone);
$("#userAddress").val(d.userAddress);
}
})
$("#save").click(function () {
//获取修改后的数据
var user={};
user.userCode = userCode;
user.userName=$("#userName").val();
user.userSex=$("#userSex").val();
user.userBirthday=$("#userBirthday").val();
user.userPhone=$("#userPhone").val();
user.userAddress=$("#userAddress").val();
$.ajax({
url:'/SSM_hospital/user/updateuser',
data:JSON.stringify(user),
type:'post',
contentType:"application/json;charset=utf-8",
dataType:'json',
success:function (d){
if(d.fig=="success"){
//添加成功
layer.alert("修改成功", {icon: 6},function () {
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
/*//表格重载 就相当于 刷新父页面的表格-dataTable是父页面的表格ID属性
parent.layui.table.reload('dataTable');*/
//关闭当前frame
parent.layer.close(index);
//
window.parent.location.reload();
});
}else
{
alert("修改用户信息失败");
}
}
})
})
})
</script>
</body>
###### 运行结果及报错内容
无
###### 我的解答思路和尝试过的方法