JavaScript - paso de variables......

 
Vista:
sin imagen de perfil

paso de variables......

Publicado por jhon jairo (18 intervenciones) el 11/03/2011 07:52:46
hola a todos:

He realizado el siguiente codigo, pero tengo un problema en la funcion modificafila(valor ) ya que no pasa la variable por el metodo get a modificamuestras.php, ya lo probe con window.open y con esta funcion si funciona.......

Alguien que porfavor me colabore....

tengo realizada la siguiente funcion:
<?php
session_start();
if($_SESSION['login']!='1')
{
header ("location: /Intranet.php");
exit;
}
else
{
$CODIGO =(isset($_GET['CODIGO']))?$_GET['CODIGO']:"";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="">

function objetoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function marcamuestras(){
var codigo=document.getElementById("CODIGO").value;
// window.open("consultaprocedimientos.php?codigo="+codigo+"","ordeninterna","width=900,height=500,scrollbars=NO");
ajax=objetoAjax();
ajax.open("GET", 'consultaprocedimientos.php?codigo='+codigo,true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
var respuesta_json = ajax.responseText;
var objeto_json = eval("("+respuesta_json+")");
var FILAS = objeto_json.items[0].FILAS;
var i=0;
while(i<FILAS){
var codigo = objeto_json.items[i].codigo;
var codlaboratorio = objeto_json.items[i].codlaboratorio;
var laboratorio = objeto_json.items[i].laboratorio;
var cantidad = objeto_json.items[i].cantidad;
var estadopreanalisis = objeto_json.items[i].estadopreanalisis;
var origen = objeto_json.items[i].origen;

var tbody = document.getElementById('tablaprocedimientos').getElementsByTagName("TBODY")[0];
var row = document.createElement("TR");
row.id="a"+i;
var td1 = document.createElement("TD");
td1.id="b"+i;
td1.appendChild(document.createTextNode(codigo));
var td2 = document.createElement("TD");
td2.appendChild(document.createTextNode(codlaboratorio));
var td3 = document.createElement("TD");
td3.appendChild(document.createTextNode(laboratorio));
var td4 = document.createElement("TD");
td4.appendChild(document.createTextNode(cantidad));
var td5 = document.createElement("TD");
td5.appendChild(document.createTextNode(estadopreanalisis));
var td6 = document.createElement("TD");
td6.appendChild(document.createTextNode(origen));

var td7 = document.createElement("TD");
td7.appendChild (document.createTextNode(" "));
var boton = document.createElement("button");
boton.type = "Submit";
boton.value = FILAS;
boton.id = codlaboratorio;
boton.innerHTML = "Modificar";
td7.appendChild (boton);

row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
row.appendChild(td6);
row.appendChild(td7);
tbody.appendChild(row);
if (boton.addEventListener) {
boton.addEventListener('click',function(){modificafila(this.id)}, false);
} else {
boton.attachEvent('onclick',function() {modificafila(this.id)});
}

i++;
}

}
}
ajax.send(null);
}

function modificafila(valor){
alert(valor);
document.forms.form1.action="modificamuestras.php?valor="+valor+"";
//window.open("modificamuestras.php?valor="+valor+"","ordeninterna","width=900,height=500,scrollbars=NO");

}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="CISSNE.css" rel="stylesheet" type="text/css" />
</head>

<body class="fondo" onload="javascript:marcamuestras();">
<blockquote>
<p>&nbsp;</p>
<form id="form1" name="form1" method="get" >
<br />
<table width="200" border="0">
<tr>
<td>CODIGO:</td>
<td><input name="CODIGO" type="text" id="CODIGO" value="<?php echo $CODIGO; ?>"></input></td>
<td><input type="button" name="consultar" value="Consultar" onclick="javascript:marcamuestras();"/></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><p><a href="/menu.php">VOLVER</a></p></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="200" border="0" id="tablaprocedimientos">
<tbody>
<tr>
<td>CODIGO MUESTRA </td>
<td>CODIGO LABORATORIO </td>
<td>LABORATORIO</td>
<td>CANTIDAD</td>
<td>ESTADO PREANALISIS </td>
<td>ORIGEN </td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</form>
</blockquote>
</body>
</html>
<?php
}
?>


la variable valor se obtiene de otra funcion
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

paso de variables......

Publicado por jhon jairo (18 intervenciones) el 12/03/2011 03:44:26
resuelto:

he remplazado las siguientes lineas:

boton.type = "Submit";
por

boton.type = "button";

y las siguientes lineas
function modificafila(valor){
alert(valor);
document.forms.form1.action="modificamuestras.php?valor="+valor+"";
//window.open("modificamuestras.php?valor="+valor+"","ordeninterna","width=900,height=500,scrollbars=NO");

}
por estas :

function modificafila(codigomuestra){
alert(codigomuestra);
location.href="modificamuestras.php?valor="+codigomuestra+"";

}
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