General
Saves an address book database as a cookie on the user’s computer. In addition, the underlying code could be very beneficial for use in other projects.
Notes
- Created by: Joe Norman
- Web Site:
- Posted: June 6, 2000
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: addressBook.js
var arrRecords = new Array();
var arrCookie = new Array();
var recCount = 0;
var strRecord=””;
expireDate = new Date;
expireDate.setDate(expireDate.getDate()+365);
function cookieVal(cookieName) {
thisCookie = document.cookie.split(“; “)
for (i = 0; i 0) {
recCount = recCount – 1;
currentRecord();
}
document.frm2.add.value = ” NEW “;
break;
default:
}
}
// Splice method Protype Function
// Peter Belesis, Internet.com
// http://www.dhtmlab.com/
if (!Array.prototype.splice) {
function array_splice(ind,cnt) {
if (arguments.length == 0) return ind;
if (typeof ind != “number”) ind = 0;
if (ind this.length) {
if (arguments.length > 2) ind = this.length;
else return [];
}
if (arguments.length
Head
Paste this code into the HEAD
section of your HTML document.
<script type=”text/javascript” src=”addressBook.js”></script>
Body
Paste this code into the BODY
section of your HTML document.
<form name="frm1" id="frm1">
<table align="center" resize="none" border="0"><tr><td align="right">Name:</td>
<td colspan="5"><input type="box" name="name" size="49" /></td>
</tr><tr><td align="right">Address:</td><td colspan="5"><input type="box" name="address" size="49" /></td></tr><td align="right">Address 2:</td><td colspan="5" align="left"><input type="box" name="address2" size="49" /></td>
<tr><td align="right">City:</td>
<td><input type="box" name="city" size="15" /></td>
<td>State:</td><td><input type="box" name="state" size="15" /></td>
<td>Zip:</td><td><input type="box" size="6" name="zip" /></td>
</tr><td align="right">Phone:</td>
<td align="left"><input type="box" name="phone" size="15" /></td>
<td align="right">Fax:</td><td align="left"><input type="box" name="fax" size="15" /></td>
<tr><td align="right">Web Page:</td><td colspan="5" align="left"><input type="box" name="address" size="49" /></td></tr><td align="right">E-Mail:</td><td colspan="5" align="left"><input type="box" name="email" size="49" /></td>
<tr><td align="right" valign="top">Comments:</td>
<td colspan="5" align="left"><input type="box" name="comment1" size="49" /><br /><input type="box" name="comment2" size="49" /><br /><input type="box" name="comment3" size="49" /><br /><input type="box" name="comment4" size="49" /><br /><input type="box" name="comment5" size="49" /></td></tr></table></form>
<form name="frm2" id="frm2">
<table align="center" border="1" resize="none"><tr><td align="center">
<input type="button" name="first" value="|<< " onclick="navigate('first');countRecords()" /><input type="button" name="previous" value=" < " onclick="navigate('previous');countRecords()" /><input type="button" name="next" value=" > " onclick="navigate('next');countRecords()" /><input type="button" name="last" value=" >>|" onclick="navigate('last');countRecords()" /><input type="box" name="actual" size="30" /></td></tr><tr><td align="center"><input type="button" name="add" value=" NEW " onclick="newRec();countRecords()" /><input type="button" name="set" value="SAVE RECORD" onclick="setRec();countRecords()" /><input type="button" name="del" value="Delete" onclick="delRec();countRecords()" /></td></tr></table></form>