快捷搜索: 王者荣耀 脱发

JS实现单选框和多选框回显

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<%--
  Created by IntelliJ IDEA.
  User: 30868
  Date: 2022/10/29
  Time: 14:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>修改页面</title>
</head>
<body>
<form action="UpdateServlet" method="get">
    姓名:<input type="text" name="name" value="${s.name}"><br>
    年龄:<input type="text" name="age" value="${s.age}"><br>
    性别:<input type="radio" name="sex" value="1" <c:if test="${s.sex==1}"></c:if> checked="checked">男
    <input type="radio" name="sex" value="0" <c:if test="${s.sex==0}"></c:if> checked="checked">女<br>
    爱好:<input type="checkbox" name="hobby" value="吃" <c:if test="${fn:contains(s.hobby,吃 )}">checked="checked"</c:if>>吃
    <input type="checkbox" name="hobby" value="喝" <c:if test="${fn:contains(s.hobby,喝 )}">checked="checked"</c:if>>喝
    <input type="checkbox" name="hobby" value="玩" <c:if test="${fn:contains(s.hobby,玩 )}">checked="checked"</c:if>>玩
    <input type="checkbox" name="hobby" value="乐" <c:if test="${fn:contains(s.hobby,乐 )}">checked="checked"</c:if>>乐<br>
    日期:<input type="date" name="time" value="${s.time}"><br>
    <input type="reset" value="重置"><br>
    <input type="submit" value="修改"><br>
</form>
</body>
</html>
单选框:性别-进行回显: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
性别:<input type="radio" name="sex" value="1" <c:if test="${s.sex==1}"></c:if> checked="checked">男
    <input type="radio" name="sex" value="0" <c:if test="${s.sex==0}"></c:if> checked="checked">女<br>
多选框:爱好-进行回显: <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
爱好:<input type="checkbox" name="hobby" value="吃" <c:if test="${fn:contains(s.hobby,吃 )}">checked="checked"</c:if>>吃
    <input type="checkbox" name="hobby" value="喝" <c:if test="${fn:contains(s.hobby,喝 )}">checked="checked"</c:if>>喝
    <input type="checkbox" name="hobby" value="玩" <c:if test="${fn:contains(s.hobby,玩 )}">checked="checked"</c:if>>玩
    <input type="checkbox" name="hobby" value="乐" <c:if test="${fn:contains(s.hobby,乐 )}">checked="checked"</c:if>>乐<br>
经验分享 程序员 微信小程序 职场和发展