javascript,点击复选框,<span></span>显示数量
<%@pagelanguage="java"import="java.util.*"pageEncoding="ISO-8859-1"%><%Stringpath=req...
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'js3.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function check(obj){
var count = 0;
var fruits = document.getElementsByName("fruit");
for(var i = 0;i<fruits.length;i++)
{
if(fruits[i].checked){
count+=parseFloat(fruits[i].value);
}
}
ssspan.innerText=count;
}
</script>
</head>
<body>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">sdf0<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">454<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">10<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">10<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">10<br>
<span id="ssspan">0</span>
</body>
</html>
谁能帮忙看一下这段代码哪里出错误了 展开
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'js3.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function check(obj){
var count = 0;
var fruits = document.getElementsByName("fruit");
for(var i = 0;i<fruits.length;i++)
{
if(fruits[i].checked){
count+=parseFloat(fruits[i].value);
}
}
ssspan.innerText=count;
}
</script>
</head>
<body>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">sdf0<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">454<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">10<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">10<br>
<input type="checkbox" name="fruit" value="10" onclick="check(this)">10<br>
<span id="ssspan">0</span>
</body>
</html>
谁能帮忙看一下这段代码哪里出错误了 展开
3个回答
展开全部
jsp哈哈
1、首先从方法名说起:function check(obj){} //js命名规则里面说:不能用关键字命名,check目测 应该是关键字
2、ssspan.innerText=count;//就这。ssspan未声明。操作看6fone的回答
3、完全是测试?
1、首先从方法名说起:function check(obj){} //js命名规则里面说:不能用关键字命名,check目测 应该是关键字
2、ssspan.innerText=count;//就这。ssspan未声明。操作看6fone的回答
3、完全是测试?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这们写不行吧,ssspan.innerText=count;
getElementById("ssspan").innerText=count;
getElementById("ssspan").innerText=count;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询