标题:哪位大师给帮忙!??我想实现两个价格2选1为标准然后再求和!!
取消只看楼主
阿拉法特v
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2013-7-9
结帖率:0
已结贴  问题点数:20 回复次数:3 
哪位大师给帮忙!??我想实现两个价格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
阿拉法特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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-416996-1-1.html




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

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