This file show a little online calculator, in the caller the span id result, listing, the id form calc_line and the. More...
Go to the source code of this file.
Functions | |
| function | cal () |
| function | Clean () |
| function | Compute () |
Variables | |
| var | p_history = "" |
| var | p_variable = "" |
This file show a little online calculator, in the caller the span id result, listing, the id form calc_line and the.
Definition in file calc.js.
| function cal | ( | ) |
Definition at line 31 of file calc.js.
References alert(), Compute(), g(), p_history, and p_variable.
{
p_variable=this.document.getElementById('inp').value;
if (p_variable.search(/^\s*$/) !=-1)
{
return;
}
try
{
Compute();
p_variable=p_variable.replace(/ /g,"");
p_variable=p_variable.replace(/\+/g,"+ ");
p_variable=p_variable.replace(/-/g,"- ");
p_variable=p_variable.replace(/\//g,"/ ");
sub=eval(p_variable);
var result=parseFloat(sub);
result=Math.round(result*100)/100;
}
catch(exception)
{
alert("Mauvaise formule\n"+p_variable);
return false;
}
p_history=p_history+'<hr>'+p_variable;
p_history+="="+result.toString();
var str_sub="<hr><p> Total :"+p_variable+" = "+result.toString()+"</p>";
this.document.getElementById("sub_total").innerHTML=str_sub;
this.document.getElementById("listing").innerHTML=p_history;
this.document.getElementById('inp').value="";
}
| function Clean | ( | ) |
| function Compute | ( | ) |
| var p_variable = "" |