| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 834 人关注过本帖
标题:哪位大师给帮忙!??我想实现两个价格2选1为标准然后再求和!!
只看楼主 加入收藏
阿拉法特v
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-7-9
结帖率:0
收藏
已结贴  问题点数:20 回复次数:5 
哪位大师给帮忙!??我想实现两个价格2选1为标准然后再求和!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
function abc(){
var abc=document.getElementsByName("cards");
document.getElementsByName("cardzhi")[0].value="";
for(var i=0; i<abc.length; i++){
if(abc[i].checked){
document.getElementsByName("cardzhi")[0].value+=abc[i].value;}}}
function startCalc(){
  interval = setInterval("calc()",1);}
function calc(){
  //alert("yy");
  fi= document.getElementsByName("firstBox");
  //alert(fi[0].value)
  se = document.getElementsByName("secondBox");
  thi = document.getElementsByName("thirdBox");
  for (i=0;i<fi.length;i++){
    thi[i].value=((fi[i].value)*1)*((se[i].value)*1);
  }
  //two = document.autoSumForm.secondBox.value;
  //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
}
function stopCalc(){
  clearInterval(interval);}
function app(){
  o=document.getElementById("aa");
  str=o.innerHTML;
  //alert(str);
  o1=document.getElementById("bb");
  //alert(o1.html);
  o1.innerHTML= o1.innerHTML+"</br>"+str;}
function sum(){//加总
  thi = document.getElementsByName("thirdBox");
  tot = document.getElementsByName('totalBox');
  tot[0].value="0";
  for(i=0;i<thi.length;i++){
    if(thi[i].value!=''){
      tot[0].value=tot[0].value*1+thi[i].value*1;}}}
</script>

<body>
<form name="autoSumForm" id="form1">
  <table width="825" border="1">
<div id="aa">
  <tr>
    <td>贴现价</td>
    <td>现金价</td>
    <td>数量</td>
    <td>小计</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="234"><input name="cards" type="checkbox" value="2.00" onclick="abc()"/>2.00 <input type="text" name="cardzhi" value=""  size="6"></td>
    <td width="168"><input type="checkbox" name="firstBox" value="2.30" onFocus="startCalc();" onBlur="stopCalc();sum();">
      2.30      <input type="text" name="cardzhi" value="" size="6"></td>
    <td width="168"><input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td width="168"><input type=text name="thirdBox" size="6"></td>
    <td width="53">&nbsp;</td>
  </tr>
  <br></div>
  <tr>
    <td>&nbsp;</td>
    <td><input type=text name="firstBox" value="1.60" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td><input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td><input type=text name="thirdBox" size="6"></td>
    <td>&nbsp;</td>
  </tr>
  <br>
  <div id="bb"><tr>
    <td>&nbsp;</td>
    <td><input type=text name="firstBox" value="5.20" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"> </td>
    <td><input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"> </td>
    <td><input type=text name="thirdBox" size="6"></td>
    <td>&nbsp;</td>
  </tr>
  </div>   
  <tr>
    <td>&nbsp;</td>
 
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>合计:
      <input type="text" name="totalBox" value="0" / size="8"></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>


</body>
</html>

搜索更多相关主题的帖子: title PUBLIC content function javascript 
2013-07-09 19:36
阿拉法特v
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-7-9
收藏
得分:0 
坐等 好心大师!!
2013-07-09 19:38
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:10 
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>无标题文档</title>
    </head>
    <script type="text/javascript">
        function GetPrice(){
            var objArray = document.getElementsByName("price_1");
           

            for (var i=0; i<objArray.length; ++i){
                if (objArray[i].checked){
                    return objArray[i].value;
                }
            }
           

            return 0;
        }
       

        function Caculate(){
            var obj = document.getElementsByName("sum_1")[0];
           

            if (obj){
                var total = document.getElementsByName("total_1")[0];
                var sum = document.getElementsByName("total")[0];
                sum.value = total.value = obj.value * GetPrice();
            }
        }
    </script>
    <style type="text/css">
    table, td{
        border : 1px solid red;
        border-collapse : collapse;
    }
    body{
        text-align : left;
        margin : 0 auto;
        width : 700px;
    }
    input[type="text"]{
        border : 0px;
        border-bottom: 1px solid black;
    }
    </style>
    <body>
    <div id="aa">
    <form name="autoSumForm" id="form1">
    <table>
      <tr>
        <td>贴现价</td>
        <td>现金价</td>
        <td>数量</td>
        <td>小计</td>
      </tr>
      <tr>
        <td width="234">
            <input name="price_1" type="radio" value="2.00" checked="checked"/>2.00</td>

        <td width="168">
            <input name="price_1" type="radio" value="2.30">2.30</td>     

        <td width="168">
            <input type="text" name="sum_1" size="6" onkeydown="if(event.keyCode==13){Caculate();}"></td>
        <td width="168">
            <input type="text" name="total_1" value="0" size="6" disabled></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>合计:
          <input type="text" name="total" value="0" size="8" disabled></td>
      </tr>
    </table>
    </form>
    </div>
    </body>
</html>
2013-07-12 02:10
阿拉法特v
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-7-9
收藏
得分:0 
谢谢版主啊!我弄了两天算是差不多了...只是还有个超级问题。 我纠结的问题是:radio取得的值是没错,但是我选择下一个单的radio值时却总是给到上单的值了,我感觉我弄得radio值是活的而不是规定选择的 ,但它好像有能选定,郁闷,因为我的没一个单都是不同产品牵扯到两个价格,麻烦你帮我看看是咋回事??

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">

function startCalc(){
  interval = setInterval("calc()",1);}

function calc(){
  //alert("yy");
  fi= document.getElementsByName("a");
  //alert(fi[0].value)
  se = document.getElementsByName("b");
  thi = document.getElementsByName("c");
  for (i=0;i<fi.length;i++){
    thi[i].value=((fi[i].value)*1)*((se[i].value)*1);
  }
  //two = document.autoSumForm.secondBox.value;
  //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
}
function GetResult()
{ document.getElementById("c").value = parseInt(document.getElementById("b").value) * radioValue; }
function ClickChange(obj){ radioValue = obj.value; GetResult();}

function stopCalc(){
  clearInterval(interval);}

function sum(){//加总
  thi = document.getElementsByName("c");
  tot = document.getElementsByName('d');
  tot[0].value="0";
  for(i=0;i<thi.length;i++){
    if(thi[i].value!=''){
      tot[0].value=tot[0].value*1+thi[i].value*1;}}}
</script>

<body>
<form name="autoSumForm" id="form1">
  <table width="825" border="1">
<div id="aa">
  <tr>
    <td>贴现价</td>
    <td>现金价</td>
    <td>数量</td>
    <td>小计</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="168"><input name="a" type=radio id="a" onclick="ClickChange(this)" value="2.00" size="6">2.00</td>
    <td width="168"><input type=radio name="a1" id="a1" value="1.00" onclick="ClickChange(this)" size="6">1.00</td>
    <td width="168"><input type=text name="b" id="b" value="" onchange="GetResult()" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td width="168"><input type=text name="c" id="c" size="6"></td>
    <td width="53">&nbsp;</td>
  </tr>
  <br></div>
  <tr>
    <td width="168"><input name="a" type=radio id="a" onclick="ClickChange(this)" value="2.00" size="6">2.00</td>
    <td width="168"><input type=radio name="a1" id="a1" value="1.00" onclick="ClickChange(this)" size="6">1.00</td>
    <td width="168"><input type=text name="b" id="b" value="" onchange="GetResult()" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td width="168"><input type=text name="c" id="c" size="6"></td>
    <td>&nbsp;</td>
  </tr>
  <br>
  <div id="bb"><tr>
    <td>&nbsp;</td>
    <td><input type=text name="a" id="a" value="5.20" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"> </td>
    <td><input type=text name="b" id="b" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"> </td>
    <td><input type=text name="c" id="c" size="6"></td>
    <td>&nbsp;</td>
  </tr>
  </div>   
  <tr>
    <td>&nbsp;</td>
 
    <td><input type=text name="a" id="a" value="1.60" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td><input type=text name="b" id="b" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
    <td><input type=text name="c" id="c" size="6"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="text" name="d" value="0" / size="8" />
      合计:</td>
    <td>&nbsp;</td>
  </tr>
  </table>
</form>


</body>
</html>
2013-07-12 03:39
阿拉法特v
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-7-9
收藏
得分:0 
原来我把radio的name给搞错了!版主帮我看看,我的每一行的GetResult是不是都要用不同的名字才能实现每一行相乘的值啊??给个方法吧版主大人???
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">

function startCalc(){
  interval = setInterval("calc()",1);}

function calc(){
  //alert("yy");
  fi= document.getElementsByName("a");
  //alert(fi[0].value)
  se = document.getElementsByName("b");
  thi = document.getElementsByName("c");
  for (i=0;i<fi.length;i++){
    thi[i].value=((fi[i].value)*1)*((se[i].value)*1);
  }
  //two = document.autoSumForm.secondBox.value;
  //document.autoSumForm.thirdBox.value = (one * 1) + (two * 1);
}
function GetResult()
{ document.getElementById("c").value = parseInt(document.getElementById("b").value) * radioValue; }
function ClickChange(obj){ radioValue = obj.value; GetResult();}

function stopCalc(){
  clearInterval(interval);}

function sum(){//加总
  thi = document.getElementsByName("c");
  tot = document.getElementsByName('d');
  tot[0].value="0";
  for(i=0;i<thi.length;i++){
    if(thi[i].value!=''){
      tot[0].value=tot[0].value*1+thi[i].value*1;}}}
</script>
<body>
<form name="autoSumForm" id="form1">
  <table width="825" border="1">
    <div id="aa">
      <tr>
        <td>贴现价</td>
        <td>现金价</td>
        <td>数量</td>
        <td>小计</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="168"><label><input name="a" type=radio id="a" value="2.00" onclick="ClickChange(this)" size="6"></label>2.00</td>
        <td width="168"><label><input type=radio name="a" id="a1" value="1.00" onclick="ClickChange(this)" size="6"></label>1.00</td>
        <td width="168"><input type=text name="b" id="b" value="" onchange="GetResult()" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
        <td width="168"><input type=text name="c" id="c" size="6"></td>
        <td width="53">&nbsp;</td>
      </tr>
      <br>
    </div>
    <tr>
      <td width="168"><label><input name="a" type=radio id="a" value="2.00" onclick="ClickChange(this)" size="6"></label>2.00</td>
        <td width="168"><label><input type=radio name="a" id="a1" value="1.00" onclick="ClickChange(this)" size="6"></label>1.00</td>
        <td width="168"><input type=text name="b" id="b" value="" onchange="GetResult()" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
      <td width="168"><input type=text name="c" id="c" size="6"></td>
      <td>&nbsp;</td>
    </tr>
    <br>
    <div id="bb">
      <tr>
        <td>&nbsp;</td>
        <td><input type=text name="a" id="a" value="5.20" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
        <td><input type=text name="b" id="b" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
        <td><input type=text name="c" id="c" size="6"></td>
        <td>&nbsp;</td>
      </tr>
    </div>
    <tr>
      <td>&nbsp;</td>
      <td><input type=text name="a" id="a" value="1.60" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
      <td><input type=text name="b" id="b" value="" onFocus="startCalc();" onBlur="stopCalc();sum();" size="6"></td>
      <td><input type=text name="c" id="c" size="6"></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="text" name="d" value="0" / size="8" />
        合计:</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
2013-07-12 11:39
有容就大
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:东土大唐
等 级:版主
威 望:74
帖 子:9048
专家分:14309
注 册:2011-11-11
收藏
得分:10 
id可以重复么?

梅尚程荀
马谭杨奚







                                                       
2013-07-12 22:46
快速回复:哪位大师给帮忙!??我想实现两个价格2选1为标准然后再求和!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046699 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved