Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/12/2011, 10:39
Gush
 
Fecha de Ingreso: mayo-2008
Mensajes: 19
Antigüedad: 15 años, 10 meses
Puntos: 0
Necesito un Script con variables

Hola,

Tengo una web de compra on-line. Quiero que la gente cuando pulse el boton "comprar" se le abra una ventana pequeña para poner la cantidad, medidas y el color del producto y que al pulsar "Enviar" se cierre y te reenvíe a lista_carrito.php

Necesito un <script> que me haga lo siguiente:
- reciba el $row_tblproducto ['idProducto']
- reciba el $_SESSION['MM_idUsuario']
- mande a la BBDD:
· Cantidad ($row_tblcarrito['intCantidad'])
· Color ($row_tblcarrito['strColor'])
· Usuario ($row_tblcarrito['idUsuario'])
· Producto ($row_tblcarrito['idProducto'])

Tengo un script hecho que me abre la ventana, me añade la cantidad pero no reconoce el idProducto...


<------------ SCRIPT ---------------------->
<script>
function abrir(idproducto)
{
self.name = 'opener';
remote = open('producto_add.php', 'remote', 'width=400,height=150,location=no,scrollbars=yes,m enubars=no,toolbars=no,resizable=yes,fullscreen=no , status=yes');
remote.focus();
}

</script>

<------------ Boton Comprar ------------>
<input type="button" name="button" id="button" value="Cantidad" onclick="javascript:abrir(<?php echo $row_tblproducto['idProducto'] ?>);"/>



<----------- Página que se abre ------->

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tblcarrito (idUsuario, idProducto, intCantidad) VALUES (%s, %s, %s)",
GetSQLValueString($_SESSION['MM_idUsuario'], "int"),
GetSQLValueString($_POST['idProducto'], "int"),
GetSQLValueString($_POST['intCantidad'], "int"));

mysql_select_db($database_conexionretol, $conexionretol);
$Result1 = mysql_query($insertSQL, $conexionretol) or die(mysql_error());
}

?>
<head><title>Añadir al Carrito</title></head>
<body>

<?php if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { ?>
<script> self.close(); </script>
<?php } else {?>

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Cantidad:</td>
<td><input type="text" name="intCantidad" value="" size="5" /></td>
<td><input type="submit" value="Añadir al Carrito" /></td>
</tr>
</table>
<input type="hidden" name="idProducto" value="$_GET['recordID']" />
<input type="hidden" name="MM_insert" value="form1" />
</form>

<?php } ?>
</body>
</html>


Fíjense que lo que se manda está en la tblproducto y lo que se tiene que guardar va en la tblcarrito. Ahún no he añadido lo de las medidas ni el color porqué tengo que crearlo en la BBDD... pero lo necesitaré en menos que canta un gallo.


¡Muchísimas gracias de antemano!