<body > <form name="f1" method="post" action="addyqlj.jsp?f=f" > <!-- cellspacing 是单元格之间的距离、cesspadding 是单元格中内容与边框的距离 --> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="mytab" id="table1"> <tr align="center" style="display: none"> <td colspan="2" background="/foodemarket/admin/commfiles/images/bg.gif" bgcolor="#FFFFFF" class="STYLE3">添加管理员<br><br><br><br><br></td> </tr> <tr align="center"> <td width="20%" align="center"> 链接名称</td> <td align="left"><span class="style1"> <input name="ljname" id="ljname" type="text" size="25" /> </span></td> </tr> <tr align="center"> <td width="20%" align="center"> 链接地址</td> <td align="left"><span class="style1"> <input name="ljurl" id="ljurl" type="text" size="55" /> </span></td> </tr> <tr align="center"> <td width="20%" align="center"> 链接图片</td> <td align="left"><span class="style1"> <%=Info.getImgUpInfo2(70) %> </span></td> </tr> <tr align="center"> <td colspan="2" height="30" align="center"> <label> <input type="submit" name="button" id="button" value="提交信息"> </label> <input type="reset" name="button2" id="button2" value="重新填写"> </td> </tr> </table> </form> </body>
时间: 2023-10-11 09:05:48 浏览: 87
这是一个 HTML 表单,用于添加管理员链接。表单中包括一个表格,表格中有三行,每行包括两个单元格。
第一行为标题,显示“添加管理员”字样。
第二行为链接名称,包括一个文本输入框和一个提示信息。
第三行为链接地址,包括一个文本输入框和一个提示信息。
第四行为链接图片,包括一个图片上传控件,用于上传链接图片。
第五行为提交按钮和重置按钮。
当用户点击提交按钮时,表单会将输入的链接名称、链接地址和链接图片上传到服务器的 addyqlj.jsp 页面进行处理。如果用户点击重置按钮,则会清空表单中的输入内容。
相关问题
优化这段代码:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>计算∑N!</title> <style type="text/css"> table { background-color: #f2f2f2; width: 600px; height: 300px; margin: 20px auto; color: black; border: 20px ridge #9999cc; } td { font-size: 20px; font-weight: bold; text-align: center; } #button { width: 180px; height: 60px; } </style> <script src="sum_factorial.js" type="text/javascript" charset="utf-8"></script> </head> <body> <table border="0" cellspacing="" cellpadding=""> <tr> <td colspan="4"> 计算∑N! </td> </tr> <tr> <td colspan="2"> 输入整数N的值: </td> <td colspan="2"> <input type="text" id="n_text" value="" /> </td> </tr> <tr> <td colspan="2"> ∑N!= </td> <td colspan="2"> <input type="text" id="sum_text" value="" /> </td> </tr> <tr> <td colspan="2"> <input type="button" name="" id="button" value="计算∑N!" onclick="show()" /> </td> <td colspan="2"> <input type="reset" value="清空" id="button" /> </td> </tr> </table> </body> </html>
以下是对这段代码的优化:
1. 在`<meta>`标签中添加`viewport`,以适应不同设备的屏幕大小。同时,将`<meta>`标签移动到`<title>`标签前面,符合 HTML 5 标准。
```html
<meta name="viewport" content="width=device-width, initial-scale=1.0">
```
2. 将样式表放到`<head>`标签内,并将`type`属性设置为`text/css`,这样浏览器可以正确解析样式表。
```html
<style type="text/css">
/* 样式表代码 */
</style>
```
3. 将`<script>`标签放到`<body>`标签底部,这样可以让页面更快地加载。
4. 将`<table>`标签的`border`、`cellspacing`和`cellpadding`属性移除,这些属性可以使用 CSS 设置。
5. 将重复的`id`属性`button`修改为`button-calculate`和`button-reset`。
6. 将`<input>`标签的`type`属性设置为`number`,这样用户只能输入数字。
7. 将`onclick`属性修改为`addEventListener()`,这样可以避免全局作用域污染。
8. 将`show()`函数改为`calculate()`,这样更符合函数的语义。
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>计算∑N!</title>
<style type="text/css">
table {
background-color: #f2f2f2;
width: 600px;
height: 300px;
margin: 20px auto;
color: black;
border: 20px ridge #9999cc;
border-collapse: collapse;
}
td {
font-size: 20px;
font-weight: bold;
text-align: center;
padding: 10px;
border: 1px solid #9999cc;
}
#button-calculate, #button-reset {
width: 180px;
height: 60px;
}
</style>
</head>
<body>
<table>
<tr>
<td colspan="4">计算∑N!</td>
</tr>
<tr>
<td colspan="2">输入整数N的值:</td>
<td colspan="2"><input type="number" id="n_text" value="" /></td>
</tr>
<tr>
<td colspan="2">∑N!=</td>
<td colspan="2"><input type="text" id="sum_text" value="" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" id="button-calculate" value="计算∑N!" /></td>
<td colspan="2"><input type="reset" id="button-reset" value="清空" /></td>
</tr>
</table>
<script src="sum_factorial.js"></script>
<script>
const buttonCalculate = document.getElementById("button-calculate");
buttonCalculate.addEventListener("click", calculate);
function calculate() {
const n = parseInt(document.getElementById("n_text").value);
const sum = sumFactorial(n);
document.getElementById("sum_text").value = sum;
}
</script>
</body>
</html>
```
注意:这里只是对 HTML 和 CSS 的优化,对于`sum_factorial.js`文件中的代码没有进行修改。
改进这段代码让它有鼠标移入图片改变的效果<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <style type="text/css"> table{ margin: 100px auto; } td{ text-align: center; } </style> </head> <body> <table border="1" width="310px" cellspacing="0" align="center" > <tr> <td>女靴</td> <td rowspan="9"><img src="../images/女靴.jpg"></td> <td>女包</td> </tr> <tr> <td>雪地靴</td> <td>男包</td> </tr> <tr> <td>冬裙</td> <td>登山鞋</td> </tr> <tr> <td>呢大衣</td> <td>皮带</td> </tr> <tr> <td>毛衣</td> <td>围巾</td> </tr> <tr> <td>棉服</td> <td>皮衣</td> </tr> <tr> <td>女裤</td> <td>男毛衣</td> </tr> <tr> <td>羽绒服</td> <td>男棉服</td> </tr> <tr> <td>牛仔裤</td> <td>男靴</td> </tr> </table> <script src="../jquery-3.7.0.js"></script> <script type="text/javascript"> $(function(){ $("tr td")mouseenter(function(){ $("img").prop("src","../ima/女靴.jpg") }) }) </script> </body> </html>
你可以在 `$("tr td")mouseenter()` 方法中,使用 `$(this)` 获取当前鼠标移入的单元格,然后再使用 `$(this).next()` 获取该单元格后面的图片元素,最后改变图片的 `src` 属性即可实现鼠标移入图片改变的效果,示例如下:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
table{
margin: 100px auto;
}
td{
text-align: center;
}
</style>
</head>
<body>
<table border="1" width="310px" cellspacing="0" align="center" >
<tr>
<td>女靴</td>
<td rowspan="9"><img src="../images/女靴.jpg"></td>
<td>女包</td>
</tr>
<tr>
<td>雪地靴</td>
<td>男包</td>
</tr>
<tr>
<td>冬裙</td>
<td>登山鞋</td>
</tr>
<tr>
<td>呢大衣</td>
<td>皮带</td>
</tr>
<tr>
<td>毛衣</td>
<td>围巾</td>
</tr>
<tr>
<td>棉服</td>
<td>皮衣</td>
</tr>
<tr>
<td>女裤</td>
<td>男毛衣</td>
</tr>
<tr>
<td>羽绒服</td>
<td>男棉服</td>
</tr>
<tr>
<td>牛仔裤</td>
<td>男靴</td>
</tr>
</table>
<script src="../jquery-3.7.0.js"></script>
<script type="text/javascript">
$(function(){
$("tr td").mouseenter(function(){
$(this).next().find("img").prop("src","../ima/女靴.jpg");
});
$("tr td").mouseleave(function(){
$(this).next().find("img").prop("src","../images/女靴.jpg");
});
});
</script>
</body>
</html>
```
在上述代码中,我使用 `$(this).next().find("img")` 获取了当前单元格后面的图片元素,并使用 `prop("src","...")` 方法改变了图片的 `src` 属性。同时,我还添加了 `mouseleave` 事件,用于在鼠标移出单元格时将图片改回原始状态。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://img-home.csdnimg.cn/images/20250102104920.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form>
编号 标题 类型 发布人 发布日期 状态 是否头条 操作 <c:forEach items="${newsList }" var="news"> ${news.nid } ${news.title } ${news.type } ${news.userName } ${news.pubtime } <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> ${news.top==0?"是":"否" } 查看 修改 <c:if test="${user.rule==0 }"> 删除 </c:if> <c:if test="${user.rule==0 }"> 审核</c:if> </c:forEach> 这是前端代码如何优化为上文你所陈述的代码
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<%-- Created by IntelliJ IDEA. User: syp Date: 2023/5/22 Time: 13:59 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Denglu</title> </head> <body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"> <fieldset style="width: auto; margin: 0px auto"> <legend> 欢迎使用常州工业职业技术学院人员管理系统 </legend>
<form action="loginSuccess.action"> 用户:<input type="text" name="username"/>
密码:<input type="password" name="password"/>
<input type="submit" value="登录"/> 注册 </form> </fieldset> </body> </html>
<form action="loginSuccess.action"> 用户:<input type="text" name="username"/>
密码:<input type="password" name="password"/>
<input type="submit" value="登录"/> 注册 </form> </fieldset>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
编号 商品名 单价 购买数量 小计 操作 <%=application.getAttribute("id") %> <%=application.getAttribute("goods_name")%>
<%=application.getAttribute("goodspic")%> <input type="button" class="decrease" value="-"> <input type="text" class="quantity" value="0"/> <input type="button" class="increase" value="+"> <input type="button" class="deldet" value="删除此商品"> 根据此代码美化表格
新闻发布系统>>新闻管理>>查询新闻 <form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form>
编号 标题 类型 发布人 发布日期 状态 是否头条 操作 <c:forEach items="${newsList }" var="news"> <input type="checkbox" name="newsIds" value="${news.nid}"> ${news.nid } ${news.title } ${news.type } ${news.userName } ${news.pubtime } <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> ${news.top==0?"是":"否" } 查看 <c:if test="${user.rule==0 || user.uid ==news.uid }"> 修改 </c:if> <c:if test="${user.rule==0 }"> 删除 </c:if> <c:if test="${user.rule==0 }"> 审核</c:if> </c:forEach> <button type="button" >批量删除</button> </body> <script type="text/javascript"> function banchDelete(){ var idsArray = document.getElementsByName("newsIds"); var nidArray=[]; for(k in idsArray){ if(idsArray[k].checked){ nidArray.push(idsArray[k].value); } } if(nidArray.length==0){ alert("请选择要删除的新闻"); return } window.location.href="./newsBanchDelete.jsp?nids="+nidArray.join(","); } </script>这段代码优化使user.rule=0的用户才能看见批量删除的按钮
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
新闻发布系统>>新闻管理>>查询新闻 <form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form>
编号 标题 类型 发布人 发布日期 状态 是否头条 操作 <c:forEach items="${newsList }" var="news"> <input type="checkbox" name="newsIds" value="${news.nid}"> ${news.nid } ${news.title } ${news.type } ${news.userName } ${news.pubtime } <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> ${news.top==0?"是":"否" } 查看 <c:if test="${user.rule==0 || user.uid ==news.uid }"> 修改 </c:if> <c:if test="${user.rule==0 }"> 删除 </c:if> <c:if test="${user.rule==0 }"> 审核</c:if> </c:forEach> <button type="button" >批量删除</button> </body> <script type="text/javascript"> function banchDelete(){ var idsArray = document.getElementsByName("newsIds"); var nidArray=[]; for(k in idsArray){ if(idsArray[k].checked){ nidArray.push(idsArray[k].value); } } if(nidArray.length==0){ alert("请选择要删除的新闻"); return } window.location.href="./newsBanchDelete.jsp?nids="+nidArray.join(","); } </script>这段代码优化使user.rule=0的用户才能看见批量删除的按钮
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)