Javascript 如何保留下拉选择 员工管理系统 .displayMessage{ 字体系列:Fontsome; 字体风格:普通; 字体大小:400; 显示:内联块; 颜色:蓝色; 背景色:#DFF2BF; 利润率:10px 22px; 字号:2em; 内容:'\f00c'; 垂直对齐:中间对齐; 填充:12px; } .下拉列表 { 左边距:730px; 边界半径:14px; 字体大小:13px; } .搜索{ 边界半径:14px; 背景色:#DFF2BF; 字体系列:Arial、Helvetica、无衬线字体; 字体:斜体; 字体大小:13px; 字体大小:粗体; 宽度:250px; } src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> $(文档).ready(函数(){ 如果(“${ViewByName}”!=”) { $('#ViewByName').val('${ViewByName}'); } }); 函数confirmplete(){ var answer=confirm(“您确定要删除该员工吗”); 若有(答复) { 警告(“删除员工”); 返回true; } 其他的 { 返回false; } } 函数confirmComplete1(){ var answer=confirm(“您确定要编辑员工详细信息吗”); 若有(答复) { 返回true; } 其他的 { 返回false; } } ${msg} 员工管理详情 开始于 包括 以 Emp.ID 员工姓名 出生日期 年收入 血型 资格 性 电话号码。 电子邮件 编辑 删除 ${emp.employeeId} ${emp.employeeName} ${emp.dateOfBirth} ${emp.annualIncome} ${emp.bloodGroup} ${emp.qualification} ${emp.sex} ${emp.phoneNumber} ${emp.email}
这是我的jsp页面如果我刷新我的页面,我的下拉列表选择将以“始终”开始,但即使在刷新页面后我仍希望选择下拉列表,如何在刷新页面后仍保留下拉列表选择。Javascript 如何保留下拉选择 员工管理系统 .displayMessage{ 字体系列:Fontsome; 字体风格:普通; 字体大小:400; 显示:内联块; 颜色:蓝色; 背景色:#DFF2BF; 利润率:10px 22px; 字号:2em; 内容:'\f00c'; 垂直对齐:中间对齐; 填充:12px; } .下拉列表 { 左边距:730px; 边界半径:14px; 字体大小:13px; } .搜索{ 边界半径:14px; 背景色:#DFF2BF; 字体系列:Arial、Helvetica、无衬线字体; 字体:斜体; 字体大小:13px; 字体大小:粗体; 宽度:250px; } src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> $(文档).ready(函数(){ 如果(“${ViewByName}”!=”) { $('#ViewByName').val('${ViewByName}'); } }); 函数confirmplete(){ var answer=confirm(“您确定要删除该员工吗”); 若有(答复) { 警告(“删除员工”); 返回true; } 其他的 { 返回false; } } 函数confirmComplete1(){ var answer=confirm(“您确定要编辑员工详细信息吗”); 若有(答复) { 返回true; } 其他的 { 返回false; } } ${msg} 员工管理详情 开始于 包括 以 Emp.ID 员工姓名 出生日期 年收入 血型 资格 性 电话号码。 电子邮件 编辑 删除 ${emp.employeeId} ${emp.employeeName} ${emp.dateOfBirth} ${emp.annualIncome} ${emp.bloodGroup} ${emp.qualification} ${emp.sex} ${emp.phoneNumber} ${emp.email},javascript,java,spring,Javascript,Java,Spring,这是我的jsp页面如果我刷新我的页面,我的下拉列表选择将以“始终”开始,但即使在刷新页面后我仍希望选择下拉列表,如何在刷新页面后仍保留下拉列表选择。清理项目和服务器,然后再次运行项目和服务器。。 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> <
清理项目和服务器,然后再次运行项目和服务器。。
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Employee Management System</title>
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
<style>
.displayMessage{
font-family:FontAwesome;
font-style:normal;
font-weight:400;
display:inline-block;
color: blue;
background-color: #DFF2BF;
margin:10px 22px;
font-size:2em;
content:'\f00c';
vertical-align:middle;
padding:12px;
}
.dropdown
{
margin-left: 730px;
border-radius: 14px;
font-size:13px;
}
.search{
border-radius: 14px;
background-color: #DFF2BF;
font-family:Arial, Helvetica, sans-serif;
font-style:italic;
font-size:13px;
font-weight:bold;
width: 250px;
}
</style>
<script>
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
if('${ViewByName}'!='')
{
$('#ViewByName').val('${ViewByName}');
}
});
</script>
<script>
function confirmComplete() {
var answer=confirm("Are you sure you want to delete the employee");
if(answer)
{
alert("deleting the Employee");
return true;
}
else
{
return false;
}
}
function confirmComplete1() {
var answer=confirm("Are you sure you want to edit the employee details");
if(answer)
{
return true;
}
else
{
return false;
}
}
</script>
</head>
<body><center>
<c:if test="${msg!= null}">
<h1 class = "displayMessage">${msg}</h1>
</c:if>
<h2>Employee Management Details </h2>
<form:form action="view.html" modelAttribute="employee" method="POST">
<select id="ViewByName" class ="dropdown" name= "drop">
<!-- <option value="r">Select....</option> -->
<option value="s">Starts With</option>
<option value="c">Consist Of</option>
<option value="e">Ends With</option>
</select>
<div id="search-inner">
<td>
<form:input path="employeeName" type="text" name="search" maxlength="30" id="searchfield" title="searchfield" value="type the name of employee to search..." class = "search" onfocus="if (this.value=='type the name of employee to search...') this.value=''"
onblur="if (this.value == '') this.value ='type the name of employee to search...'"/>
<input type="submit" name="Search" value="Search" title="Search" />
</td>
</div>
</form:form>
<table border="0" cellpadding="0" cellspacing="0">
<br>
</br>
<tr>
<td width="5%">Emp.ID</td>
<td width="22%">Employee Name</td>
<td width="6%">DOB</td>
<td width="7%">Annual Income </td>
<td width="9%">Blood group </td>
<td width="11%">Qualification</td>
<td width="7%">Sex</td>
<td width="10%">Phone No.</td>
<td width="9%">Email</td>
<td width="7%">Edit</td>
<td width="7%">Delete</td>
</tr>
<c:forEach items="${employeeList}" var="emp">
<tr>
<td>${emp.employeeId}</td>
<td>${emp.employeeName}</td>
<td>${emp.dateOfBirth}</td>
<td>${emp.annualIncome}</td>
<td>${emp.bloodGroup}</td>
<td>${emp.qualification}</td>
<td> ${emp.sex}</td>
<td>${emp.phoneNumber}</td>
<td>${emp.email}</td>
<td><a href="edit.html?ID=${emp.ID}" ><img src="Pictures/edit.png" width="15px" height="15px" onclick="return confirmComplete1()"/></a></td>
<td><a href="delete.html?ID=${emp.ID}"><img src="Pictures/delete.png" width="15px" height="15px" onclick="return confirmComplete()" /></a></td>
</tr>
</c:forEach>
</table>
<div><a href="EmployeeRegister.html"><input name="" type="button" value="Back" /></a>
</div>
</center>
</body>
</html>
请正确检查此URL
$(文档).ready(函数(){
if(“${name of class}”!=”)//在我的例子中,名称是drop
{
$(“#您的id”).val(“${name of class}”);//在我的例子中,id是ViewByName
}
});
检查。您可以将所选选项的值存储在localStorage
中。在页面加载时,检查localstorage值,如果存在,则将该选项设置为选中。可能重复的或或感谢tushar,但我希望它在ajax或JavaScription中可能重复的
clean the project and server and run the project and server again..
check this URL correctly
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
$(document).ready(function(){
if('${name of class}'!='')//in my case name is drop
{
$('#your id').val('${name of class}');//in my case id is ViewByName
}
});