Foros del Web » Programando para Internet » Javascript »

agenda de contactos

Estas en el tema de agenda de contactos en el foro de Javascript en Foros del Web. Hola muy buenos dias!! necesito ayuda con esta aplicacion. Tengo una agenda de contactos hecha con javascript y que guarda los datos en las cookies ...
  #1 (permalink)  
Antiguo 29/07/2010, 01:45
 
Fecha de Ingreso: abril-2009
Mensajes: 64
Antigüedad: 15 años
Puntos: 0
agenda de contactos

Hola muy buenos dias!!
necesito ayuda con esta aplicacion.
Tengo una agenda de contactos hecha con javascript y que guarda los datos en las cookies del usuario.
Necesitaria por favor que alguien me ayudase a insertar un boton de buscar por nombre al lado de la caja de texto.
A parte necesitaria que saltase un alert si insertamos un nombre que ya existe, y que no nos deje grabar mientras nos e cambie ese nombre.
No controlo mucho de javascript pero necesito que se asi porque es una aplicacion para usuario offline y necesito guardar
los datos en cookies, eso ya lo hace, el problema es el buscador y tal.
Gracias por todo compañeros,si alguien sabe hacerlo pues lo agradeceria, gracias de nuevo !!

el fichero js llamado 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 < thisCookie.length; i++) {
if (cookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].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[i].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[i].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[i].value = currRecord[i];
}
}
}


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[i];
}
for(var i = 0; i < endArray.length; i++) {
this[this.length] = endArray[i];
}
return removeArray;
}
Array.prototype.splice = array_splice;
}
recCount = 0;
loadCookie();
countRecords();

y el html:

<body>

<div style="float:right; width:25%; background-color:#f5f5f5; border: solid 1px #F7F7F7; font-size:4px;
display:block; clear:both">
<form name="frm1" style="font-size:4px">
<table align="center" resize="none" border="0" style="font-size:10px">
<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>

<tr>
<td align="right">City:</td>
<td><input type="box" name="city" size="15"></td>

</tr>
<td align="right">Phone:</td>
<td align="left"><input type="box" name="phone" size="8"></td>

</tr>

<td align="right">E-Mail:<td colspan="5" align="left"><input type="box" name="email" size="49"></td></tr>
<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>

</td></tr></table>
</form>
<form name="frm2">
<table align="center" border="1" resize="none" style="font-size:10px"><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>
</div>

</body>
  #2 (permalink)  
Antiguo 29/07/2010, 07:58
 
Fecha de Ingreso: julio-2003
Ubicación: Cochabamba Bolivia
Mensajes: 300
Antigüedad: 20 años, 9 meses
Puntos: 14
Respuesta: agenda de contactos

Hola.

La verdad es que el foro es para que ayuden con algun problema que tengas, pero no para que alguien te cree un codigo con tus requerimientos, la verdad no creo que nadie te cree un codigo asi por asi.

Prueba aqui:

http://www.forosdelweb.com/f65/

Talves alguien tenga tiempo y te lo haga, suerte.

Saludos.
__________________
:policia: Uno para todos y todos para uno.

Última edición por sander; 29/07/2010 a las 07:58 Razón: ortografia
  #3 (permalink)  
Antiguo 30/07/2010, 00:24
 
Fecha de Ingreso: abril-2009
Mensajes: 64
Antigüedad: 15 años
Puntos: 0
Respuesta: agenda de contactos

No quiero que nadie me lo haga......asi no se aprende.....
yo solo necesito saber como implemento las cosas y mas o menos que necesito, el codigo pues lo hago yo que para eso me tengo q romper la cabeza, solo piedo ayuda, no quiero que nadie me lo haga entero y ya esta.
Gracias

Etiquetas: agenda, cookies
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:35.