
Capturar datos del input php
Publicado por Nestor (4 intervenciones) el 12/11/2015 00:43:51
Buenas noches. A ver si alguien me puede ayudar.
Tengo un archivo llamado Presupuestos.php que contiene un form y que en la parte que tengo dudas tiene el siguiente codigo:
Una funcion javascript:
El archivo SumarPresupuesto.php tiene el siguiente codigo:
Al escribir cualquier numero en el input, el archivo SumarPresupuesto.php me captura el "id" del input, pero no el valor, y no me doy cuenta donde esta el error (u horror).
Gracias.
Tengo un archivo llamado Presupuestos.php que contiene un form y que en la parte que tengo dudas tiene el siguiente codigo:
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
<table id="prueba01">
<tr><td colspan="2" ><span style="font-weight: bold; text-decoration: underline;">
Detalles del Presupuesto:</span></td></tr>
<tr>
<td>
Prendas:
</td>
<td><input class="numeros" type="number" value="0" id="dataPREN" name="PRENDA"
onkeyup="SumaTotal(this.value,'dataESTA','dataTRANS','dataGVAR');"/></td></tr>
<tr>
<td>
Estampado:</td>
<td><input class="numeros" type="number" value="0" id="dataESTA" name="ESTAMPA"
onkeyup="SumaTotal('dataPREN',this.value,'dataTRANS','dataGVAR');"/></td></tr>
<tr>
<td>
Transporte:
</td>
<td>
<input class="numeros" type="number" value="0" id="dataTRANS" name="TRANSP"
onkeyup="SumaTotal('dataPREN','dataESTA',this.value,'dataGVAR');"/>
</td>
</tr>
<tr>
<td>
Gastos varios:
</td>
<td>
<input class="numeros" type="number" value="0" id="dataGVAR" name="GASTOS"
onkeyup="SumaTotal('dataESTA','dataESTA','dataTRANS',this.value);"/></td>
</tr>
<div id="SUMATOTAL"></div>
</table>
Una funcion javascript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function SumaTotal(val01,val02,val03,val04){
var xhr;
if(window.XMLHttpRequest){
xhr=new XMLHttpRequest();
} else {
xhr=new ActiveXObject("Microsoft.XMLHTTP");
} //ENDIF
xhr.onreadystatechange=function(){
if(xhr.readyState==4 && xhr.status==200){
document.getElementById("SUMATOTAL").innerHTML=xhr.responseText;
}
}
xhr.open("GET","SumarPresupuesto.php?PRENDA="+val01+"&ESTAMPA="+val02+"&TRANSP="+val03+"&GASTOS="+val04,true);
xhr.send();
}
1
2
3
4
5
6
7
8
9
10
<?php
$prenda= $_GET["PRENDA"];
$estampa= $_GET["ESTAMPA"];
$transporte=$_GET["TRANSP"];
$gastos= $_GET["GASTOS"];
$total=$prenda+$estampa+$transporte+$gastos;
echo "<tr><td>TOTAL</td><td><input type='number' value= '$total'/></td></tr>";?>
Al escribir cualquier numero en el input, el archivo SumarPresupuesto.php me captura el "id" del input, pero no el valor, y no me doy cuenta donde esta el error (u horror).
Gracias.
Valora esta pregunta


0