Foros del Web » Programando para Internet » Javascript »

Recoger variables de formualrio js a Php

Estas en el tema de Recoger variables de formualrio js a Php en el foro de Javascript en Foros del Web. Hola, Tengo un archivo .js que parece estar correcto porque logro pasar las variables del formulario a un archivo php, pero únicamente con una función ...
  #1 (permalink)  
Antiguo 23/01/2009, 11:40
 
Fecha de Ingreso: enero-2009
Mensajes: 8
Antigüedad: 15 años, 3 meses
Puntos: 0
Recoger variables de formualrio js a Php

Hola,

Tengo un archivo .js que parece estar correcto porque logro pasar las variables del formulario a un archivo php, pero únicamente con una función que recoge todas de golpe y yo quiero recogerlas una a una dentro de este archivo php.

El .js que envia contiene: ( no os lo pongo entero )

function printEMail() {
var s = new String("");
var msg = new String("");
var mailfrom = new String("");
var Now = new Date();
var DateStr = Now.getDate() + '.';
var year = Now.getYear();
var referencia = calcular_referencia();
var importe= CalculaTotal();
if (year < 2000) year += 1900;
if ((Now.getMonth()+1) < 10) DateStr += '0' + (Now.getMonth()+1) + '.' + year
else DateStr += (Now.getMonth()+1) + '.' + year;
msg = printMessage(DateStr);
if (Kunde.email != "") {mailfrom = Kunde.email;} else {mailfrom = "[email protected]";}
if (Kunde.paymethod == "Kreditkarte")
................................... ( corto para no extenderme y continúa ) }
else
{
s += '<form method="post" action="http://www.db-mailscript.com/cgi-bin/es/mws_mail.cgi" target="OrderWindow" onSubmit="return parent.initBasket(\'order4.html\',3000)">\n';
s += '<input type="hidden" name="From" value="' + mailfrom + '">\n';
s += '<input type="hidden" name="To" value="[email protected]">\n';
s += '<input type="hidden" name="Subject" value="Hoja de pedido: stocktelekom.com">\n';
s += '<input type="hidden" name="Message" value="' + convertMessage(msg) + '">\n';
s += '<input type="hidden" name="Attachment" value="' + printAttachment(DateStr) + '">\n';
s += '<font face="Arial, Helvetica, sans-serif" size="1"><input type="submit" value="Enviar hoja de pedido"></font></form>\n';
}
return s;
}


El archivo que se llama enviar.php contiene:
Nota: Lo magenta recoge todas las variables de golpe pero no una a una por ejemplo en el campo $amount que no se ve nada.

<HTML>
<HEAD>
<TITLE>PhP Form Example</TITLE>
</HEAD>
<BODY>

<?php
// If form is submitted with all required data then show the form
// else show error page
empty($Formulario) ?
ShowForm() :
ShowError();
exit;
?>

<?php

function ShowError () {
echo "<html><head><title>Results</title></head><body><table width=100% height=50%><tr><td><p><h2><center>Compruebe que todos los datos del formulario son correctos!!</center></h2></p></td></tr></table></body></html>\n";
} # End of function ShowError

function ShowForm () {
// Posted data
global $HTTP_POST_VARS;


// Valores constantes del comercio
$url_tpvv='https://sis-t.sermepa.es:25443/sis/realizarPago';
$clave='qwertyasdf0123456789';
$name='Comercio Pruebas';
$code='297350803';
$terminal='1';
$order=date('ymdHis');
$amount=$_POST['importe'];
$currency='978';
$transactionType='0';
$urlMerchant='http://sis-d5.sermepa.es/sis/pruebaCom.jsp';
$producto='Zapatos';
$cuerpo= "";
$campos = count($HTTP_POST_VARS);
$cont=1;
while (list ($clave, $val) = each ($HTTP_POST_VARS)) {
$cuerpo= $cuerpo."$clave : $val\n";
$cont++;
if ($cont>$campos)
break;
}


// Now, print the HTML script
echo "<html><head><title>Comercio Simulador</title></head>
<script language=JavaScript>
function calc() {
vent=window.open('','tpv','width=725,height=600,sc rollbars=no,resizable=yes,status=yes,menubar=no,lo cation=no');
document.forms[0].submit();}
</script>
<body bgcolor=white>
<form name=compra action=$url_tpvv method=post target=tpv>
<pre>
<table>
<tr><td>
<h2>Comercio de prueba.</h2>
</td></tr><tr><td>
Comercio: <font color=blue>$name</font>
</td></tr><tr><td>
FUC: <font color=blue>$code</font>
</td></tr><tr><td>
Terminal: <font color=blue>$terminal</font>
</td></tr><tr><td>
Pedido: <font color=blue>$order</font>
</td></tr><tr><td>
Producto: <font color=blue>$producto</font>
</td></tr><tr><td>
Importe: <font color=blue>$amount</font>
</td></tr><tr><td>
Tipo de Operacion: <font color=blue>$transactionType (Autorización)</font>
</td></tr><tr><td>
URL del comercio: <font color=blue>$urlMerchant</font>
</td></tr><tr><td>
Cuerpo: <font color=blue>$cuerpo</font>
</td></tr><tr><td>";

// Currency strings
if ($currency == "978") {
echo "Moneda: <font color=blue>Euros</font>";
}

echo "</td>
.................................... ( continúa ) .................................................. .........

Gracias.
Adolfo.
  #2 (permalink)  
Antiguo 23/01/2009, 12:29
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Recoger variables de formualrio js a Php

Tema trasladado a Javascript.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:25.