<select class="form-control" style ="margin-left: 20px;width:340px" id="emp_id" name="emp_id" required placeholder="Enter the Employee Id"/>
<option value="">Employee Name</option>
<% for (i = 0; i < emp_id_count; i++) {%>
<option value="<%= employee[i].emp_id %>"> <%=empname[i].emp_name %></option>
<% }; %>
</select>
这是针对视图模式我应该怎么做才能自动填充以前的值,在修改模式下为ejs中的选择框字段显示新值。
答案 0 :(得分:0)
Ejs Part
<form name="mod" id="mod" action="/employeeModule/employeeDetails/modempdet" method="post">
<label for="empid" style="color:#404040;margin-left: 50px">Employee Name <span style="color:red;font-size: 10pt">*</span></label>
<select class="form-control" style ="margin-left: 50px;width:340px" id="emp_id" name="emp_id" placeholder="Enter the Employee Id"/>
<option value="">Employee Name</option>
<% for (i = 0; i < emp_id_count; i++) {%>
<option value="<%= employee[i].emp_id %>"> <%=empname[i].emp_name %></option>
<% }; %>
</select>
节点js部分 pdbconnect.query(“从common_code_tbl中选择comm_code_desc,其中comm_code_id = $ 1”,[empAccess],function(err,resultset){ empAccess_desc = resultset.rows [ '0'] comm_code_desc;
//query to fetch other Data from Table for employee Access
pdbconnect.query("SELECT comm_code_id,comm_code_desc from common_code_tbl where code_id = 'ACC' ",function(err,result){
comm_code_empAccess=result.rows;
comm_code_empAccess_count=result.rowCount;
//query to select description of designation
pdbconnect.query("select comm_code_desc from common_code_tbl where comm_code_id=$1",[desig],function(err,resultset){
desig_desc=resultset.rows['0'].comm_code_desc;
//query to fetch other Data from Table for designation
pdbconnect.query("SELECT comm_code_id,comm_code_desc from common_code_tbl where code_id = 'DSG' ",function(err,result){
comm_code_desig=result.rows;
comm_code_desig_count=result.rowCount;
然后呈现页面