JavaScript - DIV y Ajax

 
Vista:

DIV y Ajax

Publicado por Fernanda (13 intervenciones) el 12/11/2012 16:03:17
Hola.

tengo un listado de datos y al pinchar sobre uno se debe cargar un div a traves de ajax con mas información (esto ya lo tengo listo y funcionando). El problema es que la información siempre se carga en el primer datos desplegado.

Alguien sabe como hacer para que la información del <DIV> se muestre en el dato correcto?


Ejemplo

Nombre Edad
Juan 15
Pedro 20

Pincho en el nombre (Juan) y se debe desplegar así

Juan 15
Libro Autor
libro1 xx
libro2 xx

y pincho en pedro ( en este caso los datos no aparecen debajo de pedro sino que se actualizan en Juan...

Pedro 20
Libro Autor
libro1 xx
libro2 xx
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

DIV y Ajax

Publicado por Elbio (6 intervenciones) el 13/11/2012 12:10:37
Hola:
¿Podrias mostrar el código?
Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

DIV y Ajax

Publicado por Fernanda (13 intervenciones) el 13/11/2012 16:06:03
paginaPrincipal.asp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<script language="VBScript">
 
	function ref1(var1)
 
 
	dim Link1, elemento, numVisible
 
	elemento = "DIV1"
 
 
	link1 = "PaginaConDiv.asp?Libro="&var1
 
	call cargaXML (link1, elemento)
 
	End function
 
</script>
 
 
 
<tr id="tr2">
  <td align="left" valign="top" nowrap bgcolor="<%=colortd%>" id="td2">
        <strong><a href=VBScript:ref1("<%=dato%>") ><span class="titulo2"><%=dato%></span></a></strong>
 
 
	<div id="DIV1">
	</div>
 
 
  </td>
 
</tr>
 
FIN PAGINAPRINCIPAL
 
 
 
PAGINACONDIV.ASP
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
 
<%
 
Libro= request.QueryString("Libro")
 
 
set rs = server.CreateObject ( "ADODB.Recordset" )
s = "pkg_Libro.trae_Libro(" & Libro & ")"
set rs = CONN_P.Execute(s)
end if
 
%>
 
<%IF NOT RS.EOF AND NOT RS.BOF THEN %>
	<table>
		<tr>
			<td></td>
			<td align="left" valign="top" class="texto08" width="120" ><strong>libro</strong></td>
			<td align="left" valign="top" class="texto08" width="120" ><strong>autor</strong></td>
		</tr>
		<% while not rs.eof
			Libro = rs("LIBRO")
			Autor=UCASE(RS("AUTOR"))
		%>
		<tr>
			<td align="left" valign="top" class="texto08"><%=Libro%><br></td>
			<td align="left" valign="top" class="texto08"><%=Autor%><br></td>
		</tr>
		<%
			RS.MOVENEXT
			WEND
		%>
	</table>
<%end if%>
 
FIN PAGINACONDIV.ASP
 
 
--- AJAX.JS
 
var isIE = false;
var req;
 
function cargaXML(url, elemento) {
 
	document.getElementById("NombreElemento").value = elemento;
 
    if(url==''){
        return;
    }
 
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("POST", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("POST", url, true);
            req.send();
        }
    }
}
 
function processReqChange(){
 
	var strXml = document.getElementById("NombreElemento").value;
	var detalles = document.getElementById(strXml);
 
    if(req.readyState == 4){
 
        detalles.innerHTML = req.responseText;
    } else {
        //    ...en caso contrario, le diremos al usuario que los estamos cargando:
 
    }
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar