Jemi
Posts: 1
|
| Posted: 11/17/2010, 1:15 PM |
|
Where is error that is operation not complete
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>My Calcultor 1</title>
<script type="text/javascript">
function Calculate()
{
var value = null;
for (var i=0; i<radioObject.length; i++) {
if (radioObject.checked) {
value = radioObject.value;
break ;
}
}
var A=parseInt(document.getElementById('A').value);
var B=parseInt(document.getElementById('B').value);
if (value=="Addition")
{ var add = parseFloat(A) + parseFloat(B);
document.getElementById("boxResult").value=add ;}
else if (value=="Subtraction")
{ var sub = parseFloat(A) - parseFloat(B) ;
document.getElementById("boxResult").value=sub;}
else if (value=="Multiplication")
{var mul = parseFloat(A) * parseFloat(B);
document.getElementById("boxResult").value=mul ;}
else if ((value=="Division") && B!=0)
{ var divs = parseFloat(A) / parseFloat(B);
document.getElementById("boxResult").value=divs ;}
document.write("<br />");
}
</script> </head>
<body>
<h1>My Calcultor</h1>
<form action="" method="post" >
<p>First number: <input type="text" name="input_A" size="10" id="A"/></p>
<p>Second number: <input type="text" name="input_A" size="10" id="B"/></p>
<p><input name ="op" type = "radio" value = "Addition" id="add" checked = "checked"/>Addition<input name ="op" type = "radio" value = "Subtraction" id="sub" checked = "checked" />Subtraction<input name ="op" type = "radio" value ="Multiplication" id="mul" checked = "checked" />Multiplication<input name ="op" type = "radio" value ="Division" id="divs" checked = "checked" />Division</p>
<p><input type="button" value="Calculate" name="Calculate" onclick="Calculate()"/></p>
<p>Result :<input type="text" id="boxResult"/></p>
</form>
</body>
</html>
|
 |
 |
CodeChargeMVP
Posts: 473
|
| Posted: 11/25/2010, 9:10 AM |
|
It´s just simple and easy, if you want to run any javascript code or script, you should
add an event which will add the Javascript headlines.
For example, append whatever javascript event, then you´ll see than CCS has create
the javascript headlines on the html view than put your function between this headlines,
then delete the event (because you create it just by got the headlines).
_________________
Best Regards
Entrepeneur | NT Consultant
|
 |
 |
|