-6
只有函數validateForm腳本在我的html編碼中工作。爲什麼我的兩個腳本都不能在html中工作?
菜單腳本似乎不起作用。
有人可以嘗試用我的編碼來識別這個問題嗎?
我無法從外部鏈接Java,因爲我想要發佈它的Web主機不支持該功能。 我的代碼如下:
<!DOCTYPE html>
<html>
<head>
<title>Our Portolio</title>
<style>img { background:#8A0808;
padding:6px;
border:1px solid #999999;
}
body {
font: "Trebuchet MS", Verdana, sans-serif;
font-size: 16px;
background-color: dimgrey;
color: #696969;
padding: 4px;
}
#main {
padding: 5px;
padding-left: 15px;
padding-right: 15px;
background-color: #ffffff;
border-radius: 0 0 5px 5px;
}
h1 {
font: Georgia, serif;
border-bottom: 3px solid #cc9900;
color: #996600;
font-size: 30px;
}
table {
width:100%;
}
table, th , td {
border: 3px solid grey;
border-collapse: collapse;
padding: 5px;
}
th {
text-align: middle;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
ul#menu {
padding: 0;
margin-bottom: 12px;
}
ul#menu li {
display: inline;
margin-right: 3px;
}
ul#menu li a {
background-color: #ffffff;
padding: 10px 20px;
text-decoration: none;
color: #696969;
border-radius: 4px 4px 0 0;
}
ul#menu li a:hover {
color: white;
background-color: black;
}</style>
</head>
<script>document.getElementById("foot01").innerHTML =
"<p>© " + new Date().getFullYear() + " Copywright 2014 S.S.T.O. All rights reserved.</p>";
document.getElementById("nav01").innerHTML =
"<ul id='menu'>" +
"<li><a href='index.html'>Home</a></li>" +
"<li><a href='About.html'>About</a></li>" +
"<li><a href='Our_Portfolio.html'>Our Portfolio</a></li>" +
"</ul>";</script>
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
var y = document.forms["myForm"]["pwd"].value;
//alert(x);
//alert(y);
if (y == null || x == "") {
alert("All fields must be correctly filled out");
return false;
}
if (x == "administrator" && y == "14b79d")
{
document.forms["myform"].submit()
} else
{
alert("User name and/or password is incorrect");
return false;
}
}
</script>
<script>document.getElementById("foot01").innerHTML =
"<p>© " + new Date().getFullYear() + " Copywright 2014 S.S.T.O. All rights reserved.</p>";
document.getElementById("nav01").innerHTML =
"<ul id='menu'>" +
"<li><a href='index.html'>Home</a></li>" +
"<li><a href='About.html'>About</a></li>" +
"<li><a href='Our_Portfolio.html'>Our Portfolio</a></li>" +
"</ul>";</script>
<body>
<nav id="nav01"></nav>
<div id="main">
<h1>The SSTO's portfolio</h1>
<IMG STYLE="position:absolute; TOP:78px; LEFT:1045px; WIDTH:195px; HEIGHT:65px" SRC="https://lh6.ggpht.com/EIDo8hYVBfNxwtFxpAvJ0CGtxZENQ- Qctrz5lFn6EaQrp4HKFF_Qr4TwMxKwvaa5Ffbt37I=s170">
<p><strong> If you wish to view our amazing portfolio and receive monthly trading tips: </strong></p>
<p>Please contact us at:</p>
<p> [email protected]</p>
<p>or, [email protected]</p>
<p>or, [email protected]</p>
<p>or, [email protected]</p>
<h3>Thank You</h3>
<form name="myForm" action="Answered.html" onsubmit="return validateForm()" method="post">
Username: <input type="text" name="fname"><br>
Password: <input type="password" name="pwd"><br>
<input type="submit" value="Submit">
</form>
</div>
<div></div>
<footer id="foot01"></footer>
</body>
</html>
正確地張貼您的代碼縮進。閱讀這樣的代碼非常困難。 – nisargjhaveri 2014-09-20 19:56:25
提示:不需要使用javascript創建菜單。使用HTML和CSS。您可能還想檢查「copywright」的拼寫。 – 2014-09-20 19:58:16
是「14b79d」的管理員密碼嗎?請... – sdespont 2014-09-20 19:59:11