codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Address Book Problem  ZeroShade at 02:20 on Sunday, October 29, 2006
 

I have two problems... the code keeps giving me an error on line 67. Something about it not being an object or null. How can I fix this problem? My second question is that how can I delete the first entry made? As of right now, the first entry made cannot be deleted, but if the delete button is pushed on the first entry, I would like it to delete, what would I do to the code to fix this?

Heres the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Addresses</title>
<link rel="stylesheet" href="/forum/styles.css" type="text/css" />
<SCRIPT LANGUAGE="JavaScript">
var arrRecords = new Array();
var arrCookie = new Array();
var recCount = 0;
var strRecord="";
expireDate = new Date;
expireDate.setDate(expireDate.getDate()+730);
function cookieVal(cookieName) {
thisCookie = document.cookie.split("; ")
for (i = 0; i < thisCookie.length; i++) {
if (cookieName == thisCookie.split("=")[0]) {
return thisCookie.split("=")[1];
}
}
return 0;
}
function loadCookie() {
if(document.cookie != "") {
arrRecords = cookieVal("Records").split(",");
currentRecord();
}
}
function setRec() {
strRecord = "";
for(i = 0; i < document.frm1.elements.length; i++) {
strRecord = strRecord + document.frm1.elements.value + ":";
}
arrRecords[recCount] = strRecord;
document.frm2.add.value = " NEW ";
document.cookie = "Records="+arrRecords+";expires=" + expireDate.toGMTString();
}
function newRec() {
switch (document.frm2.add.value) {
case " NEW " :
varTemp = recCount;
for(i = 0; i < document.frm1.elements.length; i++) {
document.frm1.elements.value = ""
}
recCount = arrRecords.length;
document.frm2.add.value = "CANCEL";
break;
case "CANCEL" :
recCount = varTemp;
document.frm2.add.value = " NEW ";
currentRecord();
break;
}
}
function countRecords() {
document.frm2.actual.value = "Record " + (recCount+1)+"; "+arrRecords.length+" saved records";
}
function delRec() {
arrRecords.splice(recCount,1);
navigate("previous");
setRec();
}
function currentRecord() {
if (arrRecords.length != "") {
strRecord = arrRecords[recCount];
currRecord = strRecord.split(":");
for(i = 0; i < document.frm1.elements.length; i++) {
document.frm1.elements.value = currRecord;
}
}
}
function navigate(control) {
switch (control) {
case "first" :
recCount = 0;
currentRecord();
document.frm2.add.value = " NEW ";
break;
case "last" :
recCount = arrRecords.length - 1;
currentRecord();
document.frm2.add.value = " NEW ";
break;
case "next" :
if (recCount < arrRecords.length - 1) {
recCount = recCount + 1;
currentRecord();
document.frm2.add.value = " NEW ";
}
break;
case "previous" :
if (recCount > 0) {
recCount = recCount - 1;
currentRecord();
}
document.frm2.add.value = " NEW ";
break;
default:
}
}
if (!Array.prototype.splice) {
function array_splice(ind,cnt) {
if (arguments.length == 0) return ind;
if (typeof ind != "number") ind = 0;
if (ind < 0) ind = Math.max(0,this.length + ind);
if (ind > this.length) {
if (arguments.length > 2) ind = this.length;
else return [];
}
if (arguments.length < 2) cnt = this.length-ind;
cnt = (typeof cnt == "number") ? Math.max(0,cnt) : 0;
removeArray = this.slice(ind,ind+cnt);
endArray = this.slice(ind+cnt);
this.length = ind;
for (var i = 2; i < arguments.length; i++) {
this[this.length] = arguments;
}
for(var i = 0; i < endArray.length; i++) {
this[this.length] = endArray;
}
return removeArray;
}
Array.prototype.splice = array_splice;
}
recCount = 0;
loadCookie();
countRecords();
</script>
</head>
<body>
<form name="frm1">
Name:
<input type="box" name="name" size="50" id="textbox"><br>
Address:
<input type="box" name="address" size="50" id="textbox"><br>
Phone:
<input type="box" name="phone" size="50" id="textbox"><br>
Comments:
<input type="box" name="comment1" size="50" id="textbox"><br>
<input type="box" name="comment2" size="50" id="textbox"><br>
<input type="box" name="comment3" size="50" id="textbox"><br>
<input type="box" name="comment4" size="50" id="textbox"><br>
<input type="box" name="comment5" size="50" id="textbox">
<div id="who">
Starting time:
<input type="box" name="starttime" size="48" id="textbox2"><br>
Who's working:
<input type="box" name="person" size="48" id="textbox2">
</div>
</form>
<form name="frm2">
<input type="button" name="first" value="|<< " onClick="navigate('first');countRecords()" id="caption1">
<input type="button" name="previous" value=" < " onClick="navigate('previous');countRecords()" id="caption2">
<input type="button" name="next" value=" > " onClick="navigate('next');countRecords()" id="caption3">
<input type="button" name="last" value=" >>|" onClick="navigate('last');countRecords()" id="caption4">
<input type="box" name="actual" size=23 id="record">
<input type="button" name="add" value=" NEW " onClick="newRec();countRecords()" id="caption5">
<input type="button" name="set" value="SAVE RECORD" onClick="setRec();countRecords()" id="caption6">
<input type="button" name="del" value="DELETE" onClick="delRec();countRecords()" id="caption7">
</form>
<p id="info">Insert the name, address, phone number, and any other information needed. You cannot delete the first entry, therefore, insert an entry and save over it.
</body>
</html>








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Extract first numeric string
•  Exporting reports to an excel using a template from ASP
•  Hiii!!!Problem with JTable Coloring
•  Re: Checking Multiple Forms on a Sngle Page
•  Address Book Problem
•  How to open files other then virtual folder..
•  please help incompatibility with IE 7
•  DIV Alignment When Text Size Is Changed
•  Why does my menu have specks?


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2006