js 网上购物的商品数量 在购物网站上 当看具体某个商品时在旁边会显示出 要买商品的数量 这个数量是可以改变的在数量的文本框中 紧挨的右边 有个上下点击器不知道是怎么用js写的 谢谢大家 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script> function doup(id){ var obj = document.getElementById(id); if(isNaN(obj.value)) return false; obj.value = parseInt(obj.value,10)+1;}function dodown(id){ var obj = document.getElementById(id); if(isNaN(obj.value)) return false; if(parseInt(obj.value,10)==0) obj.value = 0; else obj.value = parseInt(obj.value,10)-1;}</script> <table> <tr> <td width="200"><input id="p_0" name="p_0" style="width:100%;" value="1"></td> <td width="20"> <input type="button" style="width:20px;height:10px;float:left;" onclick="doup('p_0')"><input type="button" style="float:left;width:20;height:10px;display:inline-block;" onclick="dodown('p_0')"> </td></tr></table> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <style> body { font-size: 12px; margin: 0px; padding: 0px; } .title { height: 15px; width: 138px; display:block; text-decoration: none; cursor: pointer; text-align: center; line-height: 15px; border: 1px dashed #FFFF99; background-color: #D9D9D9 } #content { display:none; } </style> <script type="text/javascript"> <!-- var total = 0; function showCont(){ document.getElementById("content").style.display = "block"; } window.onload = function(){ total = parseInt(document.getElementById("num").value, 10); } function addNum(){ document.getElementById("num").value = ++total; } function minNum(){ total > 0 && (document.getElementById("num").value = --total); } //--> </script> </head> <body> <a href="javascript:void(0);" onclick= "showCont()" class="title">查看商品</a> <div id="content"> <img src="http://t2.baidu.com/it/u=716949918,3595690352&fm=2&gp=13.jpg"/><br/> <input type="text" id="num" value="12" style="width:22px;"/> <input type="button" value="+" onclick="addNum();" /> <input type="button" value="-" onclick="minNum();" /> </div> </body></html> 直接在网页中采用复制的方法将表格导出为excel时出错,不能导出 select设置了disabled属性 请问,如何在页面onload事件中获取事件对象 记住密码问题 动态弹出层 字符串中间含空格的情况如何用正则表达式匹配 问一个调用javascript的问题 在线等急死我了 还是基础问题 哪位大神在线啊 快帮帮我 关于Java web的 在线等 着急啊 哪里有JavaScript的参考书下载?谢谢! 求助:JScript写画笔功能! 用javascript创建层,显示在页面右下角。随滚动条滚动
<script>
function doup(id){
var obj = document.getElementById(id);
if(isNaN(obj.value)) return false;
obj.value = parseInt(obj.value,10)+1;
}
function dodown(id){
var obj = document.getElementById(id);
if(isNaN(obj.value)) return false;
if(parseInt(obj.value,10)==0) obj.value = 0;
else obj.value = parseInt(obj.value,10)-1;
}</script> <table>
<tr>
<td width="200"><input id="p_0" name="p_0" style="width:100%;" value="1"></td>
<td width="20">
<input type="button" style="width:20px;height:10px;float:left;" onclick="doup('p_0')"><input type="button" style="float:left;width:20;height:10px;display:inline-block;" onclick="dodown('p_0')">
</td>
</tr>
</table>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<style>
body {
font-size: 12px;
margin: 0px;
padding: 0px;
}
.title {
height: 15px;
width: 138px;
display:block;
text-decoration: none;
cursor: pointer;
text-align: center;
line-height: 15px;
border: 1px dashed #FFFF99;
background-color: #D9D9D9
}
#content {
display:none;
}
</style>
<script type="text/javascript">
<!--
var total = 0;
function showCont(){
document.getElementById("content").style.display = "block";
}
window.onload = function(){
total = parseInt(document.getElementById("num").value, 10);
}
function addNum(){
document.getElementById("num").value = ++total;
}
function minNum(){
total > 0 && (document.getElementById("num").value = --total);
}
//-->
</script>
</head> <body>
<a href="javascript:void(0);" onclick= "showCont()" class="title">查看商品</a>
<div id="content">
<img src="http://t2.baidu.com/it/u=716949918,3595690352&fm=2&gp=13.jpg"/><br/>
<input type="text" id="num" value="12" style="width:22px;"/>
<input type="button" value="+" onclick="addNum();" />
<input type="button" value="-" onclick="minNum();" />
</div>
</body>
</html>