# On the problem of JS automatic calculation

Source: Internet
Author: User
Tags eval

``` &lt;head&gt;  &lt;meta http-equiv= "Content-type" content= "text/html"; Charset=utf-8 "&gt;
&lt;title&gt;11&lt;/title&gt;  &lt;/head&gt;  &lt;body&gt;  &lt;script language= "JavaScript" &gt;  function Sumnum ()
{  var sumvalue  C=eval (Cc.value);  A=eval (Aa.value);  B=eval (Bb.value);  if (isNaN (a))  {a=0}  if (isNaN (b))  {b=0}  if (isNaN (c))  {b=0}  sumvalue = a+b+c;  self[' zong '].value =sumvalue;
}  &lt;/script&gt;  &lt;select id= "CC" &gt;  &lt;option value= "Sumnum" (); &gt; value is 60&lt;/option&gt; &lt;option value= "0" "Sumnum ();" &gt; value is 0&lt;/option&gt;  &lt;/select&gt;  &lt;input id= "AA" type= "text" size= "onkeyup=" Value=value.replace (/[^d.] /g, ""); Sumnum (); " &gt;  &lt;input id= "BB" type= "text" size= "onkeyup=" Value=value.replace (/[^d.] /g, ""); Sumnum (); " &gt;  &lt;input id= "zong" type= "text" size= "M" &gt;  &lt;/body&gt;  &lt;/html&gt;  &lt;script language= "JavaScript" &gt;  function Sumnum () { var sumvalue  C =parseint (document.getElementById (' cc '). Value)  a = parseint (document.getElementById (' AA '). Value) b = parseint (document.getElementById (' BB '). Value)  if (isNaN (a))  {a = 0}  if (isNaN (b))  {b = 0}  if (isNaN (c))  {b = 0}  Sumvalue = a + B + C;  document.getElementById (' Zong '). Value = Sumvalue;
}  &lt;/script&gt; &lt;select id= "CC" onchange= "Sumnum ()" &gt;  &lt;option value= &gt; value is 60&lt;/option&gt;  &lt;option value= "0" &gt; value is 0&lt;/option&gt;  &lt;/select&gt;  &lt;input id= "AA" type= "text" size= "onkeyup=" Value=value.replace (/[^d.] /g, ""); Sumnum (); " &gt;  &lt;input id= "BB" type= "text" size= "onkeyup=" Value=value.replace (/[^d.] /g, ""); Sumnum (); " &gt;  &lt;input id= "zong" type= "text" size= "&gt;"```
`     <title>11</title>   <body>  <script language= "JavaScript"  Function sumnum ()  { Var sumvalue;  var  c = parsefloat (document.getElementById ("CC"). Value) | | 0;  Var b = parsefloat (document.getElementById ("BB"). Value) | | 0;  Var a = parsefloat (document.getElementById ("AA"). Value) | | 0;  sumvalue = a+b+c;  document.getElementById ("Zong") .value =sumvalue; }  </script>  <select id= cc " onchange=" Sumnum (); "    <option value= > value is 60</option>    <option value= "0" > value is 0</option>  </select>  <input id= "AA"  type= "text"  size= "M"   Onkeyup= "Value=value.replace (/[^d.) /g, ""); Sumnum (); "  <input id= "BB"  type= "text"  size= " onkeyup=" Value=value.replace (/[^d.] /g,''); Sumnum (); "  <input id= "Zong"  type= "text"  size= " </body>   `
Related Keywords:
Related Article

## E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

## Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

## Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth \$300-1200 USD