Valentinka, ты на какую специальность учишся?
|
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
|
Цитата:
|
Здравствуйте. Не могу разобраться еще с одной задачкой. Посмотрите пожалуйста почему не работает :cray:
<html>
<head>
<title>Лабораторная работа 3</title>
</head>
<script>
document.write ("<H1>Подсчет стоимости конфет</H1><form name='forma'>Введите цену за килограмм<input type='text' name='price'><p>Введите вес в граммах<input type='text' name='gram'><p><input type='submit' value='Вычислить сумму'><p>Стоимость покупки составляет<input type='text' name='sum'></form>");
document.forma.onsubmit = function() {
var sum = (this.price.value)*((this.gram.value)/1000);
}
</script>
</html>
|
или делаю по другому, но тоже не работает :cray:
<html>
<head>
<title>Лабораторная работа 3</title>
</head>
<script>
document.write ("<H1>Подсчет стоимости конфет</H1><form name='forma'>Введите цену за килограмм<input type='text' id='price'><p>Введите вес в граммах<input type='text' id='gram'><p><input type='button' value='Вычислить сумму'OnClick='sum'><p>Стоимость покупки составляет<input type='text' name='sum'></form>");
function sum() {
var price = document.getElementById("price").value;
var gram = document.getElementById("gram").value;
var sum = parseFloat(price)/1000*parseFloat(gram);
alert(sum);
}
</script>
</html>
|
Цитата:
спасибочки:thanks: , чуть чуть не доразбиралась :) |
| Часовой пояс GMT +3, время: 07:41. |