Сделать простой калькулятор на четыре арифметических действия. Пользователь водит в строку арифметическое выражение и получает ответ после нажатия на кнопку Calculate. Например: 4+5 или 56-34.
GPL 2+
<!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="ru" lang="ru">
<head>
<title>Simple Calculator</title>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#target').submit(function() {
$.ajax({
type: "POST",
url: 'calc.php',
data: "send="+encodeURIComponent($('#filed').val()),
complete: function(data){
$('#span1').text(data.responseText);
}
});
return false;
});
});
</script>
</head>
<body>
<p>
<span>Input simple math expression ex. 5+6 and press Calculation</span>
<br/>
</p>
<form id="target" method="post" action="">
<p>
<input id="filed" type="text" name="input_field" />
<input type="submit" name="submit" value="Calculation" />
</p>
</form>
<p>
<span id="span1"></span>
</p>
</body>
</html>
Что не так? Где бардак?
P.S это и другие поделки опубликованы тут: http://code.google.com/p/php-java-test-tasks/source/browse/trunk/calc