Javascript 必须使用正确的HTML组件div和适当的约束false
规格:Javascript 必须使用正确的HTML组件div和适当的约束false,javascript,html,css,Javascript,Html,Css,规格: { background-color: #99FFFF; } h1{ color:maroon; text-align:center; font-weight: bold; font-style:italic; } table,td{ border-style: solid; padding: 10px; border-width: 5px; margin-left: 35%; width: 30%; } d
{
background-color: #99FFFF;
}
h1{
color:maroon;
text-align:center;
font-weight: bold;
font-style:italic;
}
table,td{
border-style: solid;
padding: 10px;
border-width: 5px;
margin-left: 35%;
width: 30%;
}
div{
text-align:center;
font-weight: bold;
}
#result{
font-style:italic;
color:#FF0000 ;
font-size:40px;
}
#discount{
font-size:25px;
}
function discount()
{
var s = document.getElementById("season").value;
var p = document.getElementById("price").value;
var r;
if (s=='summer')
{
document.getElementById("discount").innerHTML = "The discount is 10%";
r=(p-(p*0.1));
}
else if(s=='newyear')
{
document.getElementById("discount").innerHTML = "The discount is 5%";
r=(p-(p*0.05));
}
else
{
document.getElementById("discount").innerHTML = "The discount is 15%";
r=(p-(p*0.15));
}
document.getElementById("result").innerHTML = "The discount price: Rs " + r;
}
<!DOCTYPE html>
<html>
<head>
<title>index.html</title>
</head>
<body>
<h1>DISCOUNT PRICE</h1>
<form>
<table>
<tr>
<td>Product Name</td>
<td><input type="text" name="name" id="name" required pattern="[a-zA-Z ]+"></td>
</tr>
<tr>
<td>Product Price</td>
<td><input type="number" name="price" id="price" min="1" ></td>
</tr>
<tr>
<td>Season</td>
<td>
<select id="season" name="season">
<option value="summer">SUMMER SALE</option>
<option value="newyear">NEW YEAR SALE</option>
<option value="clearance">CLEARANCE SALE</option>
</select>
</td>
</tr>
</table>
<center><input type="button" value="GET DISCOUNT PRICE" onclick="discount()"></center>
</form>
<div id="discount"></div>
<div id="result"></div>
</body>
</html>
创建一个网页,计算特定季节产品的折扣。折扣率最高的季节为夏季(10%)、新年(5%)和清仓(15%)。折扣是按产品价格计算的。该网页应该看起来像
网页是使用HTML设计的,格式化和样式是使用CSS完成的。客户端验证是使用JavaScript执行的
网页要求
该网页的名称为“index.html”。网页背景颜色应为#99FFFF。“折扣价格”标签应为标题标签(h1),且应为斜体粗体、居中和栗色
产品名称、价格和季节应在表中。产品名称和价格分别是标签名为“name”和“price”的text
框,seasure
是标签名为“seasure”的下拉框。下拉框将具有以下值和显示值
· summer - SUMMER SALE
· newyear - NEW YEAR SALE
· clearance - CLEARANCE SALE
产品名称不应为空,且应仅包含字母和空格。价格文本框不能为空,且应为number
且value
大于零
表格的边距应为35%,外部边框样式为实心5px,宽度为30%。元素
和边框之间的空间必须为10px
应显示一个值为“获取折扣价格”的提交按钮。单击按钮,网页将计算产品的折扣价格 结果必须显示在2个div标签中,其中第一个标签的id名为“折扣”,用于显示产品的折扣%,第二个标签的id名为“结果”,用于显示产品的折扣价格。两个div标签都应
居中
与粗体
文本对齐。折扣价格的字体
必须为斜体#FF0000和40px大小,折扣%为25px。对div、折扣和result有单独的样式
CSS:
{
background-color: #99FFFF;
}
h1{
color:maroon;
text-align:center;
font-weight: bold;
font-style:italic;
}
table,td{
border-style: solid;
padding: 10px;
border-width: 5px;
margin-left: 35%;
width: 30%;
}
div{
text-align:center;
font-weight: bold;
}
#result{
font-style:italic;
color:#FF0000 ;
font-size:40px;
}
#discount{
font-size:25px;
}
function discount()
{
var s = document.getElementById("season").value;
var p = document.getElementById("price").value;
var r;
if (s=='summer')
{
document.getElementById("discount").innerHTML = "The discount is 10%";
r=(p-(p*0.1));
}
else if(s=='newyear')
{
document.getElementById("discount").innerHTML = "The discount is 5%";
r=(p-(p*0.05));
}
else
{
document.getElementById("discount").innerHTML = "The discount is 15%";
r=(p-(p*0.15));
}
document.getElementById("result").innerHTML = "The discount price: Rs " + r;
}
<!DOCTYPE html>
<html>
<head>
<title>index.html</title>
</head>
<body>
<h1>DISCOUNT PRICE</h1>
<form>
<table>
<tr>
<td>Product Name</td>
<td><input type="text" name="name" id="name" required pattern="[a-zA-Z ]+"></td>
</tr>
<tr>
<td>Product Price</td>
<td><input type="number" name="price" id="price" min="1" ></td>
</tr>
<tr>
<td>Season</td>
<td>
<select id="season" name="season">
<option value="summer">SUMMER SALE</option>
<option value="newyear">NEW YEAR SALE</option>
<option value="clearance">CLEARANCE SALE</option>
</select>
</td>
</tr>
</table>
<center><input type="button" value="GET DISCOUNT PRICE" onclick="discount()"></center>
</form>
<div id="discount"></div>
<div id="result"></div>
</body>
</html>
JS:
{
background-color: #99FFFF;
}
h1{
color:maroon;
text-align:center;
font-weight: bold;
font-style:italic;
}
table,td{
border-style: solid;
padding: 10px;
border-width: 5px;
margin-left: 35%;
width: 30%;
}
div{
text-align:center;
font-weight: bold;
}
#result{
font-style:italic;
color:#FF0000 ;
font-size:40px;
}
#discount{
font-size:25px;
}
function discount()
{
var s = document.getElementById("season").value;
var p = document.getElementById("price").value;
var r;
if (s=='summer')
{
document.getElementById("discount").innerHTML = "The discount is 10%";
r=(p-(p*0.1));
}
else if(s=='newyear')
{
document.getElementById("discount").innerHTML = "The discount is 5%";
r=(p-(p*0.05));
}
else
{
document.getElementById("discount").innerHTML = "The discount is 15%";
r=(p-(p*0.15));
}
document.getElementById("result").innerHTML = "The discount price: Rs " + r;
}
<!DOCTYPE html>
<html>
<head>
<title>index.html</title>
</head>
<body>
<h1>DISCOUNT PRICE</h1>
<form>
<table>
<tr>
<td>Product Name</td>
<td><input type="text" name="name" id="name" required pattern="[a-zA-Z ]+"></td>
</tr>
<tr>
<td>Product Price</td>
<td><input type="number" name="price" id="price" min="1" ></td>
</tr>
<tr>
<td>Season</td>
<td>
<select id="season" name="season">
<option value="summer">SUMMER SALE</option>
<option value="newyear">NEW YEAR SALE</option>
<option value="clearance">CLEARANCE SALE</option>
</select>
</td>
</tr>
</table>
<center><input type="button" value="GET DISCOUNT PRICE" onclick="discount()"></center>
</form>
<div id="discount"></div>
<div id="result"></div>
</body>
</html>
HTML:
{
background-color: #99FFFF;
}
h1{
color:maroon;
text-align:center;
font-weight: bold;
font-style:italic;
}
table,td{
border-style: solid;
padding: 10px;
border-width: 5px;
margin-left: 35%;
width: 30%;
}
div{
text-align:center;
font-weight: bold;
}
#result{
font-style:italic;
color:#FF0000 ;
font-size:40px;
}
#discount{
font-size:25px;
}
function discount()
{
var s = document.getElementById("season").value;
var p = document.getElementById("price").value;
var r;
if (s=='summer')
{
document.getElementById("discount").innerHTML = "The discount is 10%";
r=(p-(p*0.1));
}
else if(s=='newyear')
{
document.getElementById("discount").innerHTML = "The discount is 5%";
r=(p-(p*0.05));
}
else
{
document.getElementById("discount").innerHTML = "The discount is 15%";
r=(p-(p*0.15));
}
document.getElementById("result").innerHTML = "The discount price: Rs " + r;
}
<!DOCTYPE html>
<html>
<head>
<title>index.html</title>
</head>
<body>
<h1>DISCOUNT PRICE</h1>
<form>
<table>
<tr>
<td>Product Name</td>
<td><input type="text" name="name" id="name" required pattern="[a-zA-Z ]+"></td>
</tr>
<tr>
<td>Product Price</td>
<td><input type="number" name="price" id="price" min="1" ></td>
</tr>
<tr>
<td>Season</td>
<td>
<select id="season" name="season">
<option value="summer">SUMMER SALE</option>
<option value="newyear">NEW YEAR SALE</option>
<option value="clearance">CLEARANCE SALE</option>
</select>
</td>
</tr>
</table>
<center><input type="button" value="GET DISCOUNT PRICE" onclick="discount()"></center>
</form>
<div id="discount"></div>
<div id="result"></div>
</body>
</html>
index.html
折扣价
品名
产品价格
季
夏季大减价
新年大甩卖
清仓大甩卖
错误:
{
background-color: #99FFFF;
}
h1{
color:maroon;
text-align:center;
font-weight: bold;
font-style:italic;
}
table,td{
border-style: solid;
padding: 10px;
border-width: 5px;
margin-left: 35%;
width: 30%;
}
div{
text-align:center;
font-weight: bold;
}
#result{
font-style:italic;
color:#FF0000 ;
font-size:40px;
}
#discount{
font-size:25px;
}
function discount()
{
var s = document.getElementById("season").value;
var p = document.getElementById("price").value;
var r;
if (s=='summer')
{
document.getElementById("discount").innerHTML = "The discount is 10%";
r=(p-(p*0.1));
}
else if(s=='newyear')
{
document.getElementById("discount").innerHTML = "The discount is 5%";
r=(p-(p*0.05));
}
else
{
document.getElementById("discount").innerHTML = "The discount is 15%";
r=(p-(p*0.15));
}
document.getElementById("result").innerHTML = "The discount price: Rs " + r;
}
<!DOCTYPE html>
<html>
<head>
<title>index.html</title>
</head>
<body>
<h1>DISCOUNT PRICE</h1>
<form>
<table>
<tr>
<td>Product Name</td>
<td><input type="text" name="name" id="name" required pattern="[a-zA-Z ]+"></td>
</tr>
<tr>
<td>Product Price</td>
<td><input type="number" name="price" id="price" min="1" ></td>
</tr>
<tr>
<td>Season</td>
<td>
<select id="season" name="season">
<option value="summer">SUMMER SALE</option>
<option value="newyear">NEW YEAR SALE</option>
<option value="clearance">CLEARANCE SALE</option>
</select>
</td>
</tr>
</table>
<center><input type="button" value="GET DISCOUNT PRICE" onclick="discount()"></center>
</form>
<div id="discount"></div>
<div id="result"></div>
</body>
</html>
testWeb(jspackage.JSAssignmentDiscount):
正确的HTML组件div必须与适当的约束一起使用
假的
根据上述“价格”约束使用以下行-
<input type="text" name="price" id="price" pattern="[\d]+" min="1" required>
您可以将此用于价格组件:
<input type="text" name="price" required pattern="[1-9]{1}[1-9]*">
应显示一个值为“获取折扣价格”的提交按钮。 请看这一行。他使用了type=“button”,但应该是type=“submit”
实际上我现在也在问同样的问题。我们不是来帮你做作业的。我不是来帮我解决这个问题,也不是来帮我做作业的。我已经按照规范解决了所有问题,但在评估时出现了一些错误,所以我只是澄清了我犯错误的地方。