有关Javascript 警告窗弹出问题
<table border=0><tr><td class=red height=30>以下是您所选购的物品清单</td></tr></table><%response.write table1%><tr height=22<%response.write table2%> align=center class=td><td width='6%' class=blue><b>购买</td><td width='22%' class=blue><b>商品编号</td><td width='38%' class=blue><b>商品名称</td><td width='12%' class=blue><b>商品单价</td><td width='10%' class=blue><b>数量</td><td width='12%' class=blue><b>商品总价</td></tr><form name=shop_frm action='shop_bag.asp?action=shopbag' method=post><%sum=0buttoncan=" disabled"sdim=split(shop_session,"#")snum=ubound(sdim)for i=0 to snumtid=left(sdim(i),instr(sdim(i),",")-1)tnum=right(sdim(i),len(sdim(i))-instr(sdim(i),","))sql="select serial,name,price_1,price_2 from shop where hidden=1 and id="&tidset rs=conn.execute(sql)if not(rs.eof and rs.bof) thenif login_mode="" thentprice=rs("price_1")elsetprice=rs("price_2")end iftprices=tprice*tnumsum=sum+tprices%><tr align=center<%response.write table3%>><td><input type=checkbox name=pid value='<%response.write tid%>' checked class=bg_1></td><td><%response.write rs("serial")%></td><td><%response.write rs("name")%></td><td><%response.write pu&tprice%> </td><td><input type=text name=num<%response.write tid%> value='<%response.write tnum%>' size=4 onKeyUp="javascript:shop_checknum(num<%response.write tid%>,numm<%response.write tid%>);"></td><td><%response.write pu&tprices%></td></tr><%buttoncan=""end ifrs.close:set rs=nothingnexterase sdim%><tr<%response.write table4%>><%if buttoncan="" thenresponse.write "<td align=right colspan=6 height=25>您所选购的商品总的金额:<font class=red>"&pu&sum&"</font> "elseresponse.write "<td align=center colspan=6 height=25>您目前还没有选购商品"end if%></td></tr><tr<%response.write table3%>><td colspan=6 align=center height=40><input type=submit value='确认更改' onclick="return shop_checknumnull()"<%response.write buttoncan%>> <input type=button value='继续购物' onclick="location.href='shop.asp';"> <input type=button value='清空购物车' onclick="javascript:shop_clear();"<%response.write buttoncan%>> <input type=button value='去收银台' onclick="location.href='shop_pay.asp';"<%response.write buttoncan%>></td></tr></form></table><script language="Javascript"><!--function shop_checknumnull() {if (tnum>10){alert("对不起,产品数量不能超过10个!");return false;}}//--></SCRIPT>要设置每项产品购买不超过10,但怎么"对不起,产品数量不能超过10个!" 不起作用?部分程序如上,请高手指教。
参考答案:<input type=submit value='确认更改' onclick="return shop_checknumnull()"<%response.write buttoncan%>>
你response.write写出来的是什么??跟onclick=""空一个空格好些!
还有,在shop_checknumnull()函数里tnum又是什么东东???有这个变量吗??找了一下你的整个代码,发现tnum是asp上的变量!你应该检查的值是
num_<%=tid%>的表单元素的值,
还有在shop_checknumnull里还得加上
if( document.form1.num_1.value='' || isNaN(...value) ){
alert();
...focus();
...value=1;
}
再后再去判断其它的,
还得不能少于等于0