Web - whoops
This commit is contained in:
parent
7eada81ac8
commit
5af9e15880
|
@ -7,14 +7,73 @@ Andres Delikat
|
||||||
Web page programming assignment 13
|
Web page programming assignment 13
|
||||||
Chapter 14 Scripting Exercise 3
|
Chapter 14 Scripting Exercise 3
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<script language="JavaScript" src="cookieLib.js"
|
||||||
|
type="text/javascript">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script language="Javascript" type="text/javascript">
|
||||||
|
|
||||||
|
function CheckUser(name)
|
||||||
|
{
|
||||||
|
document.write("Boo")
|
||||||
|
}
|
||||||
|
|
||||||
|
function SubmitForm(Name,Password,Confirm,Value)
|
||||||
|
{
|
||||||
|
if (Password == Confirm)
|
||||||
|
{
|
||||||
|
document.write("You have successfully registered!<br>")
|
||||||
|
|
||||||
|
//Store info in cookie
|
||||||
|
if (Value)
|
||||||
|
{
|
||||||
|
var expDate = new Date(now.getTime() + (365*24*60*60*1000))
|
||||||
|
SetCookie("Username", Name, expDate, "/")
|
||||||
|
SetCookie("Password", Password, expDate, "/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.write("Error, password fields to do not match<br>")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<h1>Greetings!</h1>
|
||||||
|
Login
|
||||||
|
<form name='LoginData' method='post'>
|
||||||
|
|
||||||
|
<table border="1" bgcolor = "gray">
|
||||||
|
<tr>
|
||||||
|
<td>Name:</td>
|
||||||
|
<td><input type = "text" name = "username" align = "right"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Password:</td>
|
||||||
|
<td><input type = "password" name = "password"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Confirm password:</td>
|
||||||
|
<td><input type = "password" name = "confirm"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><input type = "checkbox" name = "savepassword"></td>
|
||||||
|
<td>Save password</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><input type = "button" value="Submit" onClick="SubmitForm(document.LoginData.username.value,document.LoginData.password.value,document.LoginData.confirm.value,document.LoginData.savepassword.value)"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<script language= "javascript" type="text/javascript">
|
<script language= "javascript" type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -14,50 +14,61 @@ type="text/javascript">
|
||||||
|
|
||||||
<script language="Javascript" type="text/javascript">
|
<script language="Javascript" type="text/javascript">
|
||||||
|
|
||||||
function SubmitForm(Name,Password,Confirm)
|
function SubmitForm(Name,Email)
|
||||||
{
|
{
|
||||||
if (Password == Confirm)
|
|
||||||
{
|
|
||||||
document.write("You have successfully registered!<br>")
|
document.write("You have successfully registered!<br>")
|
||||||
document.write(Name,"<br>") //Debug
|
|
||||||
document.write(Password,"<br>") //Debug
|
|
||||||
document.write(Confirm,"<br>") //Debug
|
|
||||||
|
|
||||||
//Store info in cookie
|
//Store info in cookie
|
||||||
}
|
var expDate = new Date(now.getTime() + (365*24*60*60*1000))
|
||||||
else
|
SetCookie("Username", Name, expDate, "/")
|
||||||
{
|
SetCookie("Email", Email, expDate, "/")
|
||||||
document.write("Error, password fields to do not match<br>")
|
SetCookie("Registered", true")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<!--<body onload="PopupRegistration()">-->
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Greetings!</h1>
|
<h1>Greetings!</h1>
|
||||||
|
|
||||||
<h2>Please register</h2>
|
<script language= "javascript" type="text/javascript">
|
||||||
<form name="CustomerData"
|
var cookieName = GetCookie("Username")
|
||||||
action="mailto:js@javascriptconcepts.com" method="post">
|
var cookieEmail = GetCookie("Email")
|
||||||
|
var registered = GetCookie("Registered")
|
||||||
|
|
||||||
|
|
||||||
|
//Keep track of the number of times visited this page
|
||||||
|
var visitCount = GetCookie("Visited")
|
||||||
|
visitCount = visitCount + 1
|
||||||
|
//var exp = new Date(now.getTime() + (365*24*60*60*1000))
|
||||||
|
var exp = new Date(99999999)
|
||||||
|
SetCookie("Visited", visitCount, exp, "/")
|
||||||
|
|
||||||
|
if (registered)
|
||||||
|
{
|
||||||
|
document.write("Welcome back, ", cookieName, "<br>")
|
||||||
|
document.write("This is visit number: ", visitCount)
|
||||||
|
}
|
||||||
|
else if (visitCount == 1 || visitCount % 3 == 0)
|
||||||
|
{
|
||||||
|
document.write("Please register")
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form name='LoginData' method='post'>
|
||||||
<table border="0">
|
<table border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Name:</td>
|
<td>Name:</td>
|
||||||
<td><input type = "text" name = "username"></td>
|
<td><input type = "text" name = "username"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Password:</td>
|
<td>Email:</td>
|
||||||
<td><input type = "password" name = "password"></td>
|
<td><input type = "text" name = "email"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Confirm password:</td>
|
<td><input type = "button" value="Submit" onClick="SubmitForm(document.LoginData.username.value,document.LoginData.email.value)"></td>
|
||||||
<td><input type = "password" name = "confirm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><input type = "button" value="Submit" onClick="SubmitForm(name.text,password.text,confirm.text)"></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue