Листинг индивидуального задания. <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <link

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link href="CSS/bootstrap.css" rel="stylesheet" type="text/css">
<script src="JS/bootstrap.js"></script>
<script>

function CalculatePrice()
{
document.forms["ShoppingForm"]["Price"].value = '';
document.forms["ShoppingForm"]["Discount"].value = '';
document.forms["ShoppingForm"]["TotalPrice"].value ='';
var count = document.forms["ShoppingForm"]["Count"].value;
var selectedGood = document.forms["ShoppingForm"]["GoodsSelect"].value;
var price;
if(count>=1) {
switch (selectedGood) {
case '0':
price = 7500*count;
break;
case '1':
price = 8000*count;
break;
case '2':
price = 9000*count;
break;
}
var discount=0;
if(count>=500)
{
document.forms["ShoppingForm"]["Discount"].value ='1% ';
discount = price*0.01;
}
if(count>=1000)
{
document.forms["ShoppingForm"]["Discount"].value = '2% ';
discount = price*0.02;
}
if(count>=2000)
{
document.forms["ShoppingForm"]["Discount"].value = '3% ';
discount = price*0.03;
}
document.forms["ShoppingForm"]["Price"].value = price;
document.forms["ShoppingForm"]["Discount"].value += discount;
document.forms["ShoppingForm"]["TotalPrice"].value = price - discount;
}
else
{
alert("Введено некорректное значение в поле Количество")
}}
function GetInformation()
{
var newWindow = window.open('','newWindow','');
newWindow.document.write("<h3>Информация о скидках</h3>");
newWindow.document.write("<br> 500 и более штук: 1% ");
newWindow.document.write("<br> 1000 и более штук: 2% ");
newWindow.document.write("<br> 2000 и более штук: 3% ");
newWindow.document.close();
}
function OpenInformationWindow() // Ну а шо ж...
{
var interval = setInterval(GetInformation(),5000);
clearInterval(interval);
}
function timer(){
var obj=document.getElementById('timer_inp');
obj.innerHTML--;
if(obj.innerHTML==0){alert('Время действия скидок истекло');setTimeout(function(){},1000);}
else{setTimeout(timer,1000);}
}
setTimeout(timer,1000);
</script>

</head>
<body >
<center>
<br>
<form name="ShoppingForm">
<label>Выберите товар</label>
<br>
<select name="GoodsSelect" onchange="CalculatePrice()">
<option value="0">Ноутбук Acer</option>
<option value="1">Ноутбук Asus</option>
<option value="2">Ноутбук HP</option>
</select>
<br>
<label>Количество</label>
<br>
<input type="text" onkeyup="CalculatePrice()" name="Count" />
<br>
<label>Цена</label>
<br>
<input type="text" name="Price" readonly />
<br>
<label>Скидка</label>
<br>
<input type="text" name="Discount" readonly />
<br>
<label>Цена со скидкой</label>
<br>
<input type="text" name="TotalPrice" readonly />
<br>
<br>
<button class="btn btn-info" onclick="GetInformation()" type="button">Получить информацию о скидках</button>
<br>
<script type="text/javascript">
document.write("Информация о браузере"+navigator.userAgent);
</script>
<div>Время действия скидок </div><div id="timer_inp">100000</div><div> секунд</div>
</div>
</div>
</form>
</center>
</body>
</html>

Рис 2.1 Пример роботы формы индивидуального задания

Рис 2.2 Пример роботы формы индивидуального задания


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: