دسته بندی کدهای آماده برای محاسبه گرها
محاسبه نتیجه یک عبارت ساده ریاضی (با javascript)
این کد، برای محاسبه نتیجه یک عبارت ریاضی به کار می رود. عملگرهای جمع، تفریق، ضرب و تقسیم را می توانید با علامت های + و - و * و / مشخص کنید :
کدها :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript">
function calc(form) {
form.result.value=eval(form.expr.value);
}
</script>
</head>
<body>
<center>
<i>Enter a math expression and click "Calculate" !</i>
<br>
<br>
<form>
<table border=3 cellspacing=2 cellpadding=5>
<tr>
<td align=center><i>Equation</i></td>
<td align=center><i>Result</i></td>
</tr>
<tr>
<td align=center><input type="text" name="expr" size="15"></td>
<td align=center><input type="text" name="result" size="15"></td>
</tr>
<tr>
<td colspan=2 align=center><input type="button" value="Calculate!" onclick="calc(this.form)"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript">
function calc(form) {
form.result.value=eval(form.expr.value);
}
</script>
</head>
<body>
<center>
<i>Enter a math expression and click "Calculate" !</i>
<br>
<br>
<form>
<table border=3 cellspacing=2 cellpadding=5>
<tr>
<td align=center><i>Equation</i></td>
<td align=center><i>Result</i></td>
</tr>
<tr>
<td align=center><input type="text" name="expr" size="15"></td>
<td align=center><input type="text" name="result" size="15"></td>
</tr>
<tr>
<td colspan=2 align=center><input type="button" value="Calculate!" onclick="calc(this.form)"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
دسته بندی کدهای آماده برای محاسبه گرها
نظرات 0 0 0