asp html :提交表单前的判断、处理js代码如何写
要在原有的网站上挂一张提交订单按钮,由于设计到多套产品,判断比较繁琐。比如说,当我选择RadioGroup3按钮中的一个是,价格栏会自动显示出价格,订购不同的产品时,下面...
要在原有的网站上挂一张提交订单按钮,由于设计到多套产品,判断比较繁琐。比如说,当我选择RadioGroup3按钮中的一个是,价格栏会自动显示出价格,订购不同的产品时,下面要自动计算总价。每套产品只能购买一种,如购买了低背沙发舒适版就不能购买豪华版。提交前要判断是否填写数量,要把数据传输到另一种页面给客户确认,再读入数据库。这个做起来实在太难了。求高人指点
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>提交订单</title>
<style type="text/css">
.order{ margin:20px 200px 0 0;border:#F00 solid 1px;
}
.morebuy,.morebuy td{ border:1px solid #999; font-size:14px;
border-collapse:collapse;
}
</style>
</head>
<body>
<table width="579" height="372" class="morebuy">
<tr>
<td width="254">产品名称</td>
<td width="102">舒适版</td>
<td width="81">豪华版(提供发票)</td>
<td width="60">数量</td>
<td width="48">价格</td>
</tr>
<form name="more" action="linepay.asp" method="post" >
<tr>
<td>卧式沙发</td>
<td> <label>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_0" />
1000元</label>
</td>
<td>
<label>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_1" />
1500元</label> </td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>电视柜</td>
<td>
<label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" />
800元</label>
</td>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_1" />
1600元</label>
</td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>低背沙发</td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_0" />
800元</label></td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_1" />
1200元</label></td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>餐厅沙发</td>
<td> <label>
<input type="radio" name="RadioGroup5" value="单选" id="RadioGroup5_0" />
8000元</label></td>
<td></td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>办公沙发</td>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" />
6000元</label></td>
<td> </td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
</table><input name="submit" type="submit" value="提交订单" />
<input name="reset" type="reset" value="重写"> <font color="#FF0000">共计<% %> 元</font>
</form>
</body>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>提交订单</title>
<style type="text/css">
.order{ margin:20px 200px 0 0;border:#F00 solid 1px;
}
.morebuy,.morebuy td{ border:1px solid #999; font-size:14px;
border-collapse:collapse;
}
</style>
</head>
<body>
<table width="579" height="372" class="morebuy">
<tr>
<td width="254">产品名称</td>
<td width="102">舒适版</td>
<td width="81">豪华版(提供发票)</td>
<td width="60">数量</td>
<td width="48">价格</td>
</tr>
<form name="more" action="linepay.asp" method="post" >
<tr>
<td>卧式沙发</td>
<td> <label>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_0" />
1000元</label>
</td>
<td>
<label>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_1" />
1500元</label> </td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>电视柜</td>
<td>
<label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" />
800元</label>
</td>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_1" />
1600元</label>
</td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>低背沙发</td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_0" />
800元</label></td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_1" />
1200元</label></td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>餐厅沙发</td>
<td> <label>
<input type="radio" name="RadioGroup5" value="单选" id="RadioGroup5_0" />
8000元</label></td>
<td></td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
<tr>
<td>办公沙发</td>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" />
6000元</label></td>
<td> </td>
<td><input name="" type="text" size=5/></td>
<td> </td>
</tr>
</table><input name="submit" type="submit" value="提交订单" />
<input name="reset" type="reset" value="重写"> <font color="#FF0000">共计<% %> 元</font>
</form>
</body>
</html> 展开
展开全部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>提交订单</title>
<style type="text/css">
.order{ margin:20px 200px 0 0;border:#F00 solid 1px;
}
.morebuy,.morebuy td{ border:1px solid #999; font-size:14px;
border-collapse:collapse;
}
</style>
<script>
function aa (val,value){
document.getElementById("show"+val).innerHTML=value * document.getElementById('count'+val).value ;
sum();
}
function sum (){
var count=5;
var sum=0
for(var i=0;i<count;i++){
sum +=+document.getElementById('show'+i).innerHTML;
}
document.getElementById('sum').innerHTML=sum;
}
function bb(obj,val){
document.getElementById("show"+val).innerHTML=+document.getElementById("show"+val).innerHTML * obj.value
}
</script>
</head>
<body>
<table width="579" height="372" class="morebuy">
<tr>
<td width="254">产品名称</td>
<td width="102">舒适版</td>
<td width="81">豪华版(提供发票)</td>
<td width="60">数量</td>
<td width="48">价格</td>
</tr>
<form name="more" action="linepay.asp" method="post" >
<tr>
<td>卧式沙发</td>
<td>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_0" onclick="aa('0','1000')"/>
<label>1000元</label>
</td>
<td>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_1" onclick="aa('0','1500')"/>
<label>1500元</label> </td>
<td><input id="count0" type="text" size=5/ value="1" onblur="bb(this,0)"></td>
<td><span id="show0"></span></td>
</tr>
<tr>
<td>电视柜</td>
<td>
<label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" onclick="aa('1','800')" />
800元</label>
</td>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_1" onclick="aa('1','1600')"/>
1600元</label>
</td>
<td><input id="count1" type="text" size=5 value="1" onblur="bb(this,1)"/></td>
<td><span id="show1"></span></td>
</tr>
<tr>
<td>低背沙发</td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_0" onclick="aa('2','800')"/>
800元</label></td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_1" onclick="aa('2','1200')"/>
1200元</label></td>
<td><input id="count2" type="text" size=5 value="1" onblur="bb(this,2)"/></td>
<td><span id="show2"></span></td>
</tr>
<tr>
<td>餐厅沙发</td>
<td>
<input type="radio" name="RadioGroup5" value="单选" id="RadioGroup5_0" onclick="aa('3','8000')"/>
<label>8000元</label></td>
<td></td>
<td><input id="count3" type="text" size=5 value="1" onblur="bb(this,3)"/></td>
<td><span id="show3"></span></td>
</tr>
<tr>
<td>办公沙发</td>
<td>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" onclick="aa('4','6000')" />
<label>6000元</label></td>
<td> </td>
<td><input id="count4" type="text" size=5 value="1" onblur="bb(this,4)"/></td>
<td><span id="show4"></span></td>
</tr>
</table><input name="submit" type="submit" value="提交订单" />
<input name="reset" type="reset" value="重写"> <font color="#FF0000">共计<span id=sum></span> 元</font>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>提交订单</title>
<style type="text/css">
.order{ margin:20px 200px 0 0;border:#F00 solid 1px;
}
.morebuy,.morebuy td{ border:1px solid #999; font-size:14px;
border-collapse:collapse;
}
</style>
<script>
function aa (val,value){
document.getElementById("show"+val).innerHTML=value * document.getElementById('count'+val).value ;
sum();
}
function sum (){
var count=5;
var sum=0
for(var i=0;i<count;i++){
sum +=+document.getElementById('show'+i).innerHTML;
}
document.getElementById('sum').innerHTML=sum;
}
function bb(obj,val){
document.getElementById("show"+val).innerHTML=+document.getElementById("show"+val).innerHTML * obj.value
}
</script>
</head>
<body>
<table width="579" height="372" class="morebuy">
<tr>
<td width="254">产品名称</td>
<td width="102">舒适版</td>
<td width="81">豪华版(提供发票)</td>
<td width="60">数量</td>
<td width="48">价格</td>
</tr>
<form name="more" action="linepay.asp" method="post" >
<tr>
<td>卧式沙发</td>
<td>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_0" onclick="aa('0','1000')"/>
<label>1000元</label>
</td>
<td>
<input type="radio" name="RadioGroup1" value="单选" id="RadioGroup1_1" onclick="aa('0','1500')"/>
<label>1500元</label> </td>
<td><input id="count0" type="text" size=5/ value="1" onblur="bb(this,0)"></td>
<td><span id="show0"></span></td>
</tr>
<tr>
<td>电视柜</td>
<td>
<label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" onclick="aa('1','800')" />
800元</label>
</td>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_1" onclick="aa('1','1600')"/>
1600元</label>
</td>
<td><input id="count1" type="text" size=5 value="1" onblur="bb(this,1)"/></td>
<td><span id="show1"></span></td>
</tr>
<tr>
<td>低背沙发</td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_0" onclick="aa('2','800')"/>
800元</label></td>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" id="RadioGroup4_1" onclick="aa('2','1200')"/>
1200元</label></td>
<td><input id="count2" type="text" size=5 value="1" onblur="bb(this,2)"/></td>
<td><span id="show2"></span></td>
</tr>
<tr>
<td>餐厅沙发</td>
<td>
<input type="radio" name="RadioGroup5" value="单选" id="RadioGroup5_0" onclick="aa('3','8000')"/>
<label>8000元</label></td>
<td></td>
<td><input id="count3" type="text" size=5 value="1" onblur="bb(this,3)"/></td>
<td><span id="show3"></span></td>
</tr>
<tr>
<td>办公沙发</td>
<td>
<input type="radio" name="RadioGroup2" value="单选" id="RadioGroup2_0" onclick="aa('4','6000')" />
<label>6000元</label></td>
<td> </td>
<td><input id="count4" type="text" size=5 value="1" onblur="bb(this,4)"/></td>
<td><span id="show4"></span></td>
</tr>
</table><input name="submit" type="submit" value="提交订单" />
<input name="reset" type="reset" value="重写"> <font color="#FF0000">共计<span id=sum></span> 元</font>
</form>
</body>
</html>
展开全部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>提交订单</title>
<style type="text/css">
.order{ margin:20px 200px 0 0;border:#F00 solid 1px;}
.morebuy,.morebuy td{border:1px solid #999; font-size:14px;border-collapse:collapse;}
</style>
</head>
<body>
<form name="more" action="linepay.asp" method="post" style="margin:0px;padding:0px;">
<table width="622" height="372" class="morebuy">
<tr>
<td width="256">产品名称</td>
<td width="104">舒适版</td>
<td width="83">豪华版(提供发票)</td>
<td width="62" align="center">数量</td>
<td width="93">价格</td>
</tr>
<tr>
<td>卧式沙发</td>
<td><input type="radio" name="a" value="1000" id="a" onclick="jiage(this.id,'shuA','jia1')"/>1000元</td>
<td><input type="radio" name="a" value="1500" id="a" onclick="jiage(this.id,'shuA','jia1')"/>1500元 </td>
<td align="center"><input name="shuA" type="text" id="shuA" size=5 onpropertychange="jiage('a','shuA','jia1')" input="jiage('a','shuA','jia1')"/></td>
<td><span id="jia1"></span> 元</td>
</tr>
<tr>
<td>电视柜</td>
<td><input type="radio" name="b" value="800" id="b" onclick="jiage(this.id,'shuB','jia2')"/>800元</td>
<td><input type="radio" name="b" value="1600" id="b" onclick="jiage(this.id,'shuB','jia2')"/>1600元</td>
<td align="center"><input name="shuB" type="text" id="shuB" size=5 onpropertychange="jiage('b','shuB','jia2')" input="jiage('b','shuB','jia2')"/></td>
<td><span id="jia2"></span> 元</td>
</tr>
<tr>
<td>低背沙发</td>
<td><input type="radio" name="c" value="800" id="c" onclick="jiage(this.id,'shuC','jia3')"/>800元</td>
<td><input type="radio" name="c" value="1200" id="c" onclick="jiage(this.id,'shuC','jia3')"/>1200元</td>
<td align="center"><input name="shuC" type="text" id="shuC" size=5 onpropertychange="jiage('c','shuC','jia3')" input="jiage('c','shuC','jia3')"/></td>
<td><span id="jia3"></span> 元</td>
</tr>
<tr>
<td>餐厅沙发</td>
<td><input type="radio" name="d" value="8000" id="d" onclick="jiage(this.id,'shuD','jia4')"/>8000元</td>
<td></td>
<td align="center"><input name="shuD" type="text" id="shuD" size=5 onpropertychange="jiage('d','shuD','jia4')" input="jiage('d','shuD','jia4')"/></td>
<td><span id="jia4"></span> 元</td>
</tr>
<tr>
<td>办公沙发</td>
<td><input type="radio" name="e" value="6000" id="e" onclick="jiage(this.id,'shuE','jia5')"/>6000元</td>
<td></td>
<td align="center"><input name="shuE" type="text" id="shuE" size=5 onpropertychange="jiage('e','shuE','jia5')" input="jiage('e','shuE','jia5')"></td>
<td><span id="jia5"></span> 元</td>
</tr>
</table>
<input name="submit" type="submit" value="提交订单" />
<input name="reset" type="reset" value="重写"><span style="color:red" id="Tolat">共计元</span>
</form>
<script>
//获取对象
function $(id){
return document.getElementById(id)
}
//只允许数量输入数字
function Ban(obj){
var obj=$(obj);
if(obj){
obj.onkeypress=function(){
var keyCode=event.keyCode||event.which;
if(keyCode!=46||keyCode!=8||keyCode!=37||keyCode!=39){
if(!(keyCode>=48&&keyCode<=57)||(keyCode>=96&&keyCode<=105)){
return false;
}
}
}
obj.onpaste=function(){return false;}
}
}
Ban("shuA");Ban("shuB");Ban("shuC");Ban("shuD");Ban("shuE");
//为了通用特编写一个取值函数
function radioValue(id){
var num=0;
var obj=document.getElementsByName(id)
for(var i=0;i<obj.length;i++){
if (obj[i].checked){
num=obj[i].value
break;
}
}
return num;
}
//计算所有商品总价
function Tolt(){
var cont=5;
var num=0;
for(var i=1;i<=cont;i++){
num+=eval($("jia"+i).innerHTML);
}
$("Tolat").innerHTML="共计 "+num+" 元";
}
//适时更新价格和总价
function jiage(A,B,C){
var Bv=$(B).value;
if(Bv==""||isNaN(Bv)||Bv<1){$(B).value=1;}
$(C).innerHTML=radioValue(A)*$(B).value;
Tolt();
}
</script>
</body>
</html>
*********************************************************
你的代码写得有点乱,我给你重新整理了一下,我想你要的效果应该就是这样的~
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>提交订单</title>
<style type="text/css">
.order{ margin:20px 200px 0 0;border:#F00 solid 1px;}
.morebuy,.morebuy td{border:1px solid #999; font-size:14px;border-collapse:collapse;}
</style>
</head>
<body>
<form name="more" action="linepay.asp" method="post" style="margin:0px;padding:0px;">
<table width="622" height="372" class="morebuy">
<tr>
<td width="256">产品名称</td>
<td width="104">舒适版</td>
<td width="83">豪华版(提供发票)</td>
<td width="62" align="center">数量</td>
<td width="93">价格</td>
</tr>
<tr>
<td>卧式沙发</td>
<td><input type="radio" name="a" value="1000" id="a" onclick="jiage(this.id,'shuA','jia1')"/>1000元</td>
<td><input type="radio" name="a" value="1500" id="a" onclick="jiage(this.id,'shuA','jia1')"/>1500元 </td>
<td align="center"><input name="shuA" type="text" id="shuA" size=5 onpropertychange="jiage('a','shuA','jia1')" input="jiage('a','shuA','jia1')"/></td>
<td><span id="jia1"></span> 元</td>
</tr>
<tr>
<td>电视柜</td>
<td><input type="radio" name="b" value="800" id="b" onclick="jiage(this.id,'shuB','jia2')"/>800元</td>
<td><input type="radio" name="b" value="1600" id="b" onclick="jiage(this.id,'shuB','jia2')"/>1600元</td>
<td align="center"><input name="shuB" type="text" id="shuB" size=5 onpropertychange="jiage('b','shuB','jia2')" input="jiage('b','shuB','jia2')"/></td>
<td><span id="jia2"></span> 元</td>
</tr>
<tr>
<td>低背沙发</td>
<td><input type="radio" name="c" value="800" id="c" onclick="jiage(this.id,'shuC','jia3')"/>800元</td>
<td><input type="radio" name="c" value="1200" id="c" onclick="jiage(this.id,'shuC','jia3')"/>1200元</td>
<td align="center"><input name="shuC" type="text" id="shuC" size=5 onpropertychange="jiage('c','shuC','jia3')" input="jiage('c','shuC','jia3')"/></td>
<td><span id="jia3"></span> 元</td>
</tr>
<tr>
<td>餐厅沙发</td>
<td><input type="radio" name="d" value="8000" id="d" onclick="jiage(this.id,'shuD','jia4')"/>8000元</td>
<td></td>
<td align="center"><input name="shuD" type="text" id="shuD" size=5 onpropertychange="jiage('d','shuD','jia4')" input="jiage('d','shuD','jia4')"/></td>
<td><span id="jia4"></span> 元</td>
</tr>
<tr>
<td>办公沙发</td>
<td><input type="radio" name="e" value="6000" id="e" onclick="jiage(this.id,'shuE','jia5')"/>6000元</td>
<td></td>
<td align="center"><input name="shuE" type="text" id="shuE" size=5 onpropertychange="jiage('e','shuE','jia5')" input="jiage('e','shuE','jia5')"></td>
<td><span id="jia5"></span> 元</td>
</tr>
</table>
<input name="submit" type="submit" value="提交订单" />
<input name="reset" type="reset" value="重写"><span style="color:red" id="Tolat">共计元</span>
</form>
<script>
//获取对象
function $(id){
return document.getElementById(id)
}
//只允许数量输入数字
function Ban(obj){
var obj=$(obj);
if(obj){
obj.onkeypress=function(){
var keyCode=event.keyCode||event.which;
if(keyCode!=46||keyCode!=8||keyCode!=37||keyCode!=39){
if(!(keyCode>=48&&keyCode<=57)||(keyCode>=96&&keyCode<=105)){
return false;
}
}
}
obj.onpaste=function(){return false;}
}
}
Ban("shuA");Ban("shuB");Ban("shuC");Ban("shuD");Ban("shuE");
//为了通用特编写一个取值函数
function radioValue(id){
var num=0;
var obj=document.getElementsByName(id)
for(var i=0;i<obj.length;i++){
if (obj[i].checked){
num=obj[i].value
break;
}
}
return num;
}
//计算所有商品总价
function Tolt(){
var cont=5;
var num=0;
for(var i=1;i<=cont;i++){
num+=eval($("jia"+i).innerHTML);
}
$("Tolat").innerHTML="共计 "+num+" 元";
}
//适时更新价格和总价
function jiage(A,B,C){
var Bv=$(B).value;
if(Bv==""||isNaN(Bv)||Bv<1){$(B).value=1;}
$(C).innerHTML=radioValue(A)*$(B).value;
Tolt();
}
</script>
</body>
</html>
*********************************************************
你的代码写得有点乱,我给你重新整理了一下,我想你要的效果应该就是这样的~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个纯ASP+HTML的网站不可能投入到真正到实际应用中。注册信息、会话什么的都需要加密,ASP能加密吗?这个用ASP.NET几个控件就解决了。ASP是客户端脚本语言代码,几乎已经淘汰了,现在都用ASP.NET(服务器端脚本语言)编写网站,特别是大型电子商务网站。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询