javascript实现自动求和
function total(){
var i=0;
for(j=1;j<=20;j++)
{
var step="step"+j;
if(document.getElementById(step)){
if(document.getElementById(step).checked==true)
{
i=i+parseInt(document.getElementById(step).value);
}
}
}
document.getElementById("total").innerHTML = i;
}
function Resetvalue(){
for(j=1;j<=20;j++)
{
if(document.getElementById("step"+j)!=null){
document.getElementById("step"+j)&0;}
document.getElementById("total").innerHTML = "0";}
}
function allselect()
{
for(j=1;j<=20;j++)
{
if(document.getElementById("step"+j)!=null){
document.getElementById("step"+j).checked=true;}
}
var ischecked=0;
var obj=document.getElementById("thisform");
for(k=0;k<obj.vom.length;k++)
{
if(obj.vom[k].checked)
ischecked=1;
}
if(ischecked==0)
{
obj.vom[1].checked=true;
}
total();
}
html部分
<form name="thisform">
<input name="step1" type="checkbox" value="1" onClick="total()"/>1<br/>
<input name="step2" type="checkbox" value="2" onClick="total()"/>2<br/>
<input name="step3" type="checkbox" value="3" onClick="total()"/>3<br/>
<input name="step4" type="checkbox" value="4" onClick="total()"/>4<br/>
<input name="step5" type="checkbox" value="5" onClick="total()"/>5<br/>
<input name="step6" type="checkbox" value="6" onClick="total()"/>6<br/>
<div id="total" >0</div>
<input type="button" name="Submit2" value="全选" onclick="allselect()" >
<input type="reset" name="Submit2" value="重置" onclick="Resetvalue()" >
</form>
---------------------------------HTML部分2,这是我加上去的,只做参考。
<SCRIPTLANGUAGE=javascript> function sumNum() {var number1= isNaN(parseInt(num1.value,10))?0:parseInt(num1.value,10);var number2= isNaN(parseInt(num2.value,10))?0:parseInt(num2.value,10);var number3= isNaN(pars
相关文档:
第三章 DOM Scripting DOM编程
DOM scripting is expensive, and it's a common performance bottleneck in rich web applications. This chapter discusses the areas of DOM scripting that can have a negative effect on an application's responsiveness and gives recommendations o ......
function db()
{
//活动编号
var activeid = Request.Form("activeid");
//用户名
var username = Request.Form("username");
//手机号码
var mobile = Request.Form("mobile");
var conn= Server.CreateObject("ADODB.connection");
var rs= Serve ......
Closure中文翻译为闭包.字面上来理解就是"封闭的包".(这是一句废话)
闭包是什么?
书面解释为:
所谓“闭包”,指的是一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分。
我认为闭包就是能够读/写函数内部的某些变量的子函数,并将这些变量保存 ......