html中js调用input的id,name正确但是读不出值

本文介绍了一种常见HTML表单问题的解决方案,即如何将type属性从number更改为text以适应不同的输入需求。
原因是 type="number",改为 type = "text",
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <!-- <link rel="stylesheet" href="<%=request.getContextPath() %>/css2/index2.css" type="text/css"></link> --> <link rel="stylesheet" href="<%=request.getContextPath() %>/css/theme.blue.css" type="text/css"></link> <body> <form action="<%=request.getContextPath() %>/g?m=getList" method="post"> <table id="myTable" class="tablesorter-blue"> <thead> <tr> <td colspan="8"><input type="text" name="name" id="MyName"> <input type="button" value="查询" onclick="chaxun()"> </td> </tr> <tr> <th>序号</th> <th>名称</th> <th>联系人</th> <th>电话</th> <th>地址</th> <th>备注</th> <th>信誉</th> <th>操作</th> </tr> </thead> <tbody id="biao"> </tbody> </table> </form> </body> <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/js/random.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.tablesorter.js"></script> <script type="text/javascript" src="<%=request.getContextPath() %>/My97DatePicker/WdatePicker.js"></script> <script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script> <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script> <script type="text/javascript"> let name=$("#name") $.post("<%=request.getContextPath()%>/my?my=zhan", {"name":name}, function (obj){ for (let i = 0; i < obj.length; i++) { $("#biao").append("<tr>" + "<td>"+obj[i].cid+"</td>" + "<td>"+obj[i].cname+"</td>" + "<td>"+obj[i].name+"</td>" + "<td>"+obj[i].dian+"</td>" + "<td>"+obj[i].dizi+"</td>" + "<td>"+obj[i].bei+"</td>" + "<td>"+obj[i].xin+"</td>" + "</tr>") } } ) </script> </html> 为啥报错啊
最新发布
12-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值