|
| TEMARIO ANTERIOR | Principal| |
Este scrip es parecido a los otros dos que están en el temario principal, sólo que lo ingenioso de este, es la siguiente idea, que pasaría si deseo ingresar información en una hoja y que esa información se transmita a otra que genera un reporte, bueno la funcionalidad es simple pero no tenemos que usar PHP y el fin es el mismo, no sobrecargar el servidor con consultas inecesarias y hacer la mayor parte desde el cliente.
COMO FUNCIONAEl funcionamiento es simple se incluye gus_query_string.js en el archivo destino y se llama a la función getQueryString(), la que nos creará un arreglo QUERY['clave'] donde se almacenaran los nombres de los campos y sus contenidos y esa arreglo lo podemos usar para escribir o calcular cosas con esos datos en la hoja destino con la funcion getQuery('clave') obtenemos una cadena vacía cuando no está definido un campo que desde el arreglo daría undefined como dato. Prueba a la derecha como clave poner gusgus, es la unica foto que esta disponible al usarla como clave
DESCARGA DEL ZIP CON LOS 3 ARCHIVOS de EJEMPLO y LA FOTO ~ 13k |
CONSTRUYE UNA CREDENCIALSI USAS gusgus COMO CLAVE TIENE FOTO |
/* This version of JavaScript Query_String can be used by anyone who is not intented
to do profit directly with this code, it means you can not sale the code as is,
you can use it ont your web or php project, or put in a CD Magazine, if you really
do profit with your project and my code consider sharing them :P.
If you want to include the Query_String in some web editor, do not remove this legend.
The lastest version can be found at
http://www.compunauta.com/forums/linux/programacion/java/gus_query_string.html
This is Open and Free Software, madgus@gmail.com, gustavo@compunauta.com
*/
var QUERY=new Object();
function getQueryString(){
var RE = new RegExp('\\+','gi');
var QUERY_STRING=document.location+"";
QUERY_STRING=QUERY_STRING.replace(RE," ");
var QUERY_KEY="VERSION";
var QUERY_DES="2006_madgus@gmail.com";
QUERY[QUERY_KEY]=QUERY_DES;
var vpos;
pos=QUERY_STRING.indexOf("?");
if (pos != -1){
QUERY_STRING=QUERY_STRING.substring(pos+1,QUERY_STRING.length);
while ((pos = QUERY_STRING.indexOf("&"))!=-1){
QUERY_KEY=QUERY_STRING.substring(0,pos);
QUERY_STRING=QUERY_STRING.substring(pos+1,QUERY_STRING.length);
addQuery(QUERY_KEY);
}
if (QUERY_STRING.length!=0){
addQuery(QUERY_STRING);
}
}else{return;}
}
function addQuery(QUERY_KEY){
//this query key is a substring having whole key=escape(val);
vpos=QUERY_KEY.indexOf("=");
if(vpos!=-1){
QUERY_DES=unescape(QUERY_KEY.substring(vpos+1,QUERY_KEY.length));
QUERY_KEY=QUERY_KEY.substring(0,vpos);
QUERY[QUERY_KEY]=QUERY_DES;
}else{
QUERY_DES="";
QUERY[QUERY_KEY]=QUERY_DES;
}
}
function getQuery(QUERY_KEY){
if (QUERY_KEY==""){return "";}
if(QUERY[QUERY_KEY]!=undefined){
return QUERY[QUERY_KEY];
}else {return "";}
}