JS realize the increase and decrease of the number of shopping cart, JS realize the self-increment and self-reduction of shopping cart quantity
<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>JS realize the increase and decrease of the number of shopping cart, JS realize the self-increment and self-reduction of shopping cart quantity</title></Head><Body><Center><Table><TR><TD>1</TD><TD><spanonclick= "Changenum (this,1)"style= "Cursor:pointer;">+</span><inputtype= "text"value=""onblur= "Checknum (this)" /><spanonclick= "Changenum (this,-1)"style= "Cursor:pointer;">-</span></TD></TR><TR><TD>2</TD><TD><spanonclick= "Changenum (this,1)"style= "Cursor:pointer;">+</span><inputtype= "text"value=""onblur= "Checknum (this)" /><spanonclick= "Changenum (this,-1)"style= "Cursor:pointer;">-</span></TD></TR><TR><TD>3</TD><TD><spanonclick= "Changenum (this,1)"style= "Cursor:pointer;">+</span><inputtype= "text"value=""onblur= "Checknum (this)" /><spanonclick= "Changenum (this,-1)"style= "Cursor:pointer;">-</span></TD></TR></Table></Center><Scripttype= "Text/javascript">functionChecknum (obj) {if(Obj.value>Ten) {Obj.value= Ten; Alert ('Max 10!'); }}functionChangenum (obj,num) {varinput=getParent (obj). getElementsByTagName ("input"); for(varI=0; I<Input.length;i++) { if(Input[i].type=="text") { if(Input[i].value== "") Input[i].value=num; ElseInput[i].value=Input[i].value- 0 +num; } if(Input[i].value== "-1") Input[i].value= 0; if(Input[i].value== " One") Input[i].value= Ten; } }//get parent-to-imagefunctiongetParent (obj) {if(typeof(obj)!= "Object") {obj=document.getElementById (obj);} if(obj)returnobj.parentelement||Obj.parentnode;}</Script></Body></HTML>
JS realize the increase and decrease of the number of shopping cart, JS realize the self-increment and self-reduction of shopping cart quantity