Ver Mensaje Individual
  #9 (permalink)  
Antiguo 06/05/2011, 15:47
SideEfect
 
Fecha de Ingreso: mayo-2011
Mensajes: 38
Antigüedad: 13 años
Puntos: 0
Respuesta: consulta y onchage

Cita:
Iniciado por alexg88 Ver Mensaje
Como no vas a subir nada mediante un formulario mejor que sean de tipo button. Los submit son para formularios.
buenas de nuevo ,he estado mirando el enlace que pusistes y me ha sido de gran ayude ,buscando me encontre con un codigo parecido al tuyo asi que decidi inplementarlo ,sin embargo por alguna razon no me funciona.....llevo todo el dia mirando que error tengo pero no lo encuentro ,y cuando ejecuto el pj2 me sale un error diciendo :"Error de lectura XML: declaración de texto o XML en un lugar distinto del principio de la entidad
Ubicación: http://localhost/prueba/coprom/ej2.php
Número de línea 16, columna 1:"<?xml version='1.0' encoding='ISO-8859-1'?><datos><pruducto><![CDATA[]]></producto></datos>
^




pagina 1.php
<script language="JavaScript">
function nuevoAjax()
{
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 traerDatos()
{
var cod=document.getElementById("cod").value;
var materia=document.getElementById("producto");


var ajax=nuevoAjax();
ajax.open("POST", "ej2.php", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("v="+cod);

ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
var respuesta=ajax.responseXML;
materia.value=respuesta.getElementsByTagName("prod ucto")[0].childNodes[0].data;

}
}
}
</script>



codigo<input type="button" name="mas" id="cod" value="-" style="color:red;height:20px; width:20px" onclick= " traerDatos(); document.getElementById('cantidad').value = parseInt(document.getElementById('cantidad').value ) - 1" title="" />

<input name="cod" type="text" id="cantidad" size="1" value="" readonly />

<input type="button" name="menos" value="+" id="cod" style="color:red;height:20px; width:20px" onclick=" traerDatos(); document.getElementById('cantidad').value = parseInt(document.getElementById('cantidad').value ) + 1" title="" "/>





pag2.php


<?php
$v=$_POST["v"];
$conexion=mysql_connect("localhost", "root", "root");
mysql_select_db("COPROM", $conexion);
$resultado=mysql_query("SELECT producto FROM t_mat WHERE cod='$v'");
$registro=mysql_fetch_row($resultado);
$xml="<?xml version='1.0' encoding='ISO-8859-1'?>";
$xml.="<datos>";
$xml.="<producto><![CDATA[$registro[0]]]></producto>";
$xml.="</datos>";
header("Content-type: text/xml");
echo $xml;
?>

sabrias decirme el error que tengo te lo agradeceria enormemente