Ver Mensaje Individual
  #8 (permalink)  
Antiguo 16/02/2007, 12:21
Arkhel
 
Fecha de Ingreso: agosto-2006
Mensajes: 34
Antigüedad: 17 años, 8 meses
Puntos: 0
Re: Paginado grid; obtener valores del control <A/>

Script 1: Jscript2.js
// JScript File
var isIE = false;
var controles;
var req;
//CAMBIAR LA R POR UNA P
var url = "httR://localhost:2926/WebSite4/pagina.aspx"
//var url = "httR://amiranda/qacenter/Ajax/QAProcess.aspx"
//var prefijo = "ctl00_ContentPlaceHolder1_";
var precision = 27;//length del ctl00_ContentPlaceHolder1_ esto lo agrega el visual al control
//Si le das view source y te fijas en el nombre del control y no lo tiene "ctl00_ContentPlaceHolder1_"
//dale a la variable precision 0
//var consultaCaso = "../Control de Consultado/ConsultaCaso.aspx";
function Proceso(datos, execute, control) {
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
req.onreadystatechange = Mensajes(objeto);
req.open("POST", url, true);
req.send(datos);
}
else if (window.ActiveXObject)
{
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req)
{
if (execute=="nonquery")
{
// if (control=="IniciarSesion")
//{

// req.onreadystatechange = IniciarSesion;
//}
//else
//{

req.onreadystatechange = Mensajes;
// }
}
if (execute=="reader")
{
controles = control;
req.onreadystatechange = TraerDatos;
}

req.open("POST", url, true);

req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

req.send(datos);


}
}
}
function Mensajes() {

if (req.readyState == 4) {


if (req.status == 200) {


var items = req.responseXML.getElementsByTagName("mensaje");
for (var i = 0; i < items.length; i++)
{
messages=getElementTextNS("", "msgbox", items[i], 0);

if (messages=="Se agregó satisfactoriamente")
{
alert(messages);
}
else
{
if (Mid(String(messages),1,9)=="Concedido")
{

window.location=Mid(String(messages),10,0)
}else
{
alert("El usuario o el password es incorrecto.");
//document.getElementById("HLinkRecuperar").innerTex t = "Olvido su contraseña. Haga click aqui para recuperla.";
}
}
}
} else {
alert("Problema al intentar obtener el documento XML:\n" + req.statusText);

}
}
}

function TraerDatos() {
if (req.readyState == 4) {
if (req.status == 200) {
if (controles =="DataGrid") {
var itemss = req.responseXML.getElementsByTagName("mensaje");

for (var i = 0; i < itemss.length; i++)
{
messages=getElementTextNS("", "msgbox", itemss[i], 0);
alert(messages);
}
memoriaGrid(1,0);
}
else {
alert("NO ES GRID")
}
}
else {
alert("Problema al intentar obtener el documento XML:\n" + req.statusText);
}
}
}
// Obtiene el texto de un elemento de un documento XML
// incluyendo elementos usando espacios de nombre (namespaces)
function getElementTextNS(prefix, local, parentElem, index) {
var result = "";
if (prefix && isIE) {
// IE/Windows way of handling namespaces
result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
} else {
// the namespace versions of this method
// (getElementsByTagNameNS()) operate
// differently in Safari and Mozilla, but both
// return value with just local name, provided
// there aren't conflicts with non-namespace element
// names
result = parentElem.getElementsByTagName(local)[index];
}
if (result) {
// get text, accounting for possible
// whitespace (carriage return) text nodes
if (result.childNodes.length > 1) {
return result.childNodes[1].nodeValue;
} else {
return result.firstChild.nodeValue;
}
} else {
return "n/a";
}
}
/************************************************** *****/

function Agregarmodulo(objetos, value, content) {


/*if (objetos.type=="text")
{
objetos.value = content;
}
else
{*/
var opt;
opt = document.createElement("option");
opt.value = value;
opt.appendChild(content);
objetos.appendChild(opt);
//}

}
function Mid(s, n, c){
// Devuelve una cadena desde la posición n, con c caracteres
// Si c = 0 devolver toda la cadena desde la posición n

var numargs=Mid.arguments.length;

// Si sólo se pasan los dos primeros argumentos
if(numargs<3)
c=s.length-n+1;

if(c<1)
c=s.length-n+1;
if(n+c >s.length)
c=s.length-n+1;
if(n>s.length)
return "";

return s.substring(n-1,n+c-1);
}
function SelectAll(obj, th){
var chk;

if (obj!=null){

chk = document.getElementById(th);
if (chk!=null){chk.checked=obj.checked;}
chk = document.getElementById(th);
if (chk!=null){chk.checked=obj.checked;}
chk = document.getElementById(th);
if (chk!=null){chk.checked=obj.checked;}
chk = document.getElementById(th);
if (chk!=null){chk.checked=obj.checked;}
}
}
function UnSelectAll(todos, ids)
{
var arr =document.getElementsByTagName('input');
for(i=0;i<arr.length;i++)
{
if(arr[i].type=="checkbox")
{
if(Mid(arr[i].id, 12, 0)=="todos" + String(todos) + String(ids))
arr[i].checked = false;
}

}
}
function SelectId(obj, idlength, ids)

{
var arr =document.getElementsByTagName('input');
for(i=0;i<arr.length;i++)
{ //se barre el arreglo de inputs
if(arr[i].type=="checkbox")
{
if (ids>0)
{
//son 12 posiciones de la cadena CheckModulo + 1, una posicion que ocupa el
//len del Idlenthg (puesto que el idlength tambien se pone en la cadena
//despues de CheckModulo, ej. checkmodulo2. +
if(Mid(arr[i].id, (precision + 12 + idlength), 0)==ids && arr[i].disabled==false)
SelectAll(obj, arr[i].id);

}
if (ids==-1)
{
//Variable precision = ctl00_ContentPlaceHolder1_ 27 caracteres

if ((Mid(arr[i].id,precision, 11)) == "CheckModulo" && arr[i].disabled == false)
SelectAll(obj, arr[i].id);

}
if (ids==-2)
{

if ((Mid(arr[i].id,precision, 6)) == "Checks" && arr[i].disabled == false)
SelectAll(obj, arr[i].id);

}

}
}
}

Última edición por Arkhel; 16/02/2007 a las 12:28