Foros del Web » Programando para Internet » PHP »

Duda en programacion

Estas en el tema de Duda en programacion en el foro de PHP en Foros del Web. Hola amigos soy nuevo en este foro almenos como usuario. Pero suelo consultar dudas aki por lo general encuentro respuesta pero hoy no :P vi ...
  #1 (permalink)  
Antiguo 10/06/2009, 00:44
 
Fecha de Ingreso: junio-2009
Mensajes: 3
Antigüedad: 14 años, 10 meses
Puntos: 0
Duda en programacion

Hola amigos soy nuevo en este foro almenos como usuario.
Pero suelo consultar dudas aki por lo general encuentro respuesta pero hoy no :P
vi el tema de alguien con un detalle parecido.
Bueno el caso es ke estoy haciendo un cotizador de productos y todo anda bien solo que kiero hacer un cambio.
al terminar de seleccionar tu producto kiero dos botones
uno que sea "agregar un nuevo porducto?"
y otro ke sea "cotizar ya"
lo primero ke hice para resolver fue poner una casilla de seleccion ke decia
"kiero otro producto"
Si era si solo lo agrego a una bariable. si era no ya mandava el correo con la cotizacion.
el problema es ke ya no lo kiero kon la casilla
kiero ke sean botones ambos
para que sea mas facil para mis clientes
pero no se como meter dos botones sunmit distintos en el mismo form
no puedo poner el codigo porke esta muy extenso :P

Si me explike kreo bueno les dejo esta es la pagina "abastecedorapromocion.com/COTIZACION.php"
  #2 (permalink)  
Antiguo 10/06/2009, 01:11
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Duda en programacion

es igual.. asigna un name por cada submit, debe ser significativo...

y luego comparas en tu script cual boton fue presionado...

Código PHP:
if ( ! empty($_POST['agregar']))
{
 
// ...
}
elseif ( ! empty(
$_POST['cotizar']))
{
  
// ...

__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 10/06/2009, 04:08
(Desactivado)
 
Fecha de Ingreso: diciembre-2008
Mensajes: 32
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: Duda en programacion

creo que la respuesta idonea a tu pregunta se jugaria un poco con javascript...

pues yo lo haria algo asi:

Código HTML:
<script>
function comp(valor){
document.NOMBREDEFORM.tmp.value=valor;
document.NOMBREDEFORM.submit();
}
</script>

<form name="NOMBREDEFORM" id="NOMBREDEFORM" action...>
<input type="hidden" name="tmp">
<input type="button" name="agregar" onclick="comp(1)"><input type="button" name="agregar" onclick="comp(2)">
</form> 

y ya en el PHP comparar

Código PHP:
<?
$tmp
=$_GET['tmp'];
if (
$tmp==1){
..........
} elseif(
$tmp==2) {
..........
}


al menos esa seria mi maneraespero te sirva...:-)
?>
  #4 (permalink)  
Antiguo 10/06/2009, 09:56
 
Fecha de Ingreso: junio-2009
Mensajes: 3
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Duda en programacion

este es el codigo que tenia ya funcionando con seleccion:

Código PHP:
<?php 
/* Cotizacion */
$item1=$_GET['item1'];
$cant1=$_GET['cant1'];
$item2=$_GET['item2'];
$cant2=$_GET['cant2'];
$item3=$_GET['item3'];
$cant3=$_GET['cant3'];
$item4=$_GET['item4'];
$cant4=$_GET['cant4'];
$item5=$_GET['item5'];
$cant5=$_GET['cant5'];
/* Producto */
$tipo=$_GET['tipo'];
$Producto=$_GET['Producto'];
$cant=$_GET['cant'];

if (
$cotizar == 2)
{
$cotizar 0;
header ("Location: send.php?name=$name&email=$email&url=$url&phone=$phone&domicilio=$domicilio&sub=cotizacion&item1=$item1&item2=$item2&item3=$item4&item5=$item5&cant1=$cant1&cant2=$cant2&cant3=$cant3&cant4=$cant4&cant5=$cant5&tipo=$tipo&Producto=$Producto&Acabado=$Acabado&Calibre=$Calibre&Medidas=$Medidas&TPP=$TPP&color=$color&Espesor=$Espesor&cant=$cant");
}
else
{
}


?>


<script language='javascript' type="text/javascript">
function reemplazarGuion(cadena)
{
var re, r, result;
re = /_/i;
r = cadena.replace(re," ");
re = /Espana/i;
result = r.replace(re,"Espa\xf1a");
return(result);

}

function type1() 
{
var p2;
p=document.carrito.tipo[document.carrito.tipo.selectedIndex].value;
p2 = reemplazarGuion(document.carrito.tipo[document.carrito.tipo.selectedIndex].value);
document.carrito.tipo[document.carrito.tipo.selectedIndex].value = p2;

var type1_=new Array("");
var type1stnames_=new Array("Seleccione Producto");

var type1_Acero_Galvanizado1=new Array("","Lamina_Lisa","ROLLO");
var type1stnames_Acero_Galvanizado1=new Array("Seleccione Producto","Lamina Lisa","ROLLO");

var type1_Acero_Galvanizado2=new Array("","Lamina_Tipo_R101","Lamina_Tipo_RN100","Lamina_Tipo_R90","Losacero_seccion_25","Lamina_Tipo_KR_18");
var type1stnames_Acero_Galvanizado2=new Array("Seleccione Producto","Lamina Tipo R101","Lamina Tipo RN100/35","Lamina Tipo R90","Losacero seccion 25","Lamina Tipo KR 18");

var type1_Translucidos=new Array("","Lamina_para_R101","Lamina_para_RN100","Lamina_para_R90","Lamina_para_R72","Lamina_Tipo_4","Liner_Panel","Rollo_Liner_Panel_090_de_4","Policarbonato");
var type1stnames_Translucidos=new Array("Seleccione Producto","Lámina para R101","Lámina para RN100/35","Lámina para R90","Lámina para R72","Lamina Tipo 4","Liner Panel","Rollo Liner Panel 090 de 4'","Policarbonato");

var type1_Panel=new Array("","PANEL_PARA_CUBIERTA","PANEL_PARA_MURO");
var type1stnames_Panel=new Array("Seleccione Producto","PANEL PARA CUBIERTA","PANEL PARA MURO");

var type1_Tejas=new Array("","TEJA_FIBROCEMENTO","TEJA_METALICA");
var type1stnames_Tejas=new Array("Seleccione Producto","TEJA DE FIBROCEMENTO","TEJA METALICA");

<!-- tipoProducto-ARRAYS -->
seleccion=eval("type1_"+p);
seleccionNames=eval("type1stnames_"+p);
cuantos_add=seleccion.length;
document.carrito.Producto.length=cuantos_add;
for(i=0;i<cuantos_add;i++)
{
document.carrito.Producto.options[i].value=seleccion[i];
document.carrito.Producto.options[i].text=seleccionNames[i];
if (seleccion[i]=="") 
{
document.carrito.Producto.options[i].selected = true;
}
}
}
</script>

<html xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>abastecedorapromocion.com - CONTACTO</title>
<meta name="DESCRIPTION" content="">
<meta name="KEYWORDS" content="">
<meta name="GENERATOR" content="Parallels Plesk Sitebuilder 4.5.0">
<link href="css/styles.css?template=aa-09&colorScheme=blue&header=headers1&button=buttons3" rel="stylesheet" type="text/css">
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<script type="text/javascript">
function stoperror(){
return true
}
window.onerror=stoperror
</script>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" style="background-image: url('images/main_bg.gif?template=aa-09&colorScheme=blue&header=headers1&button=buttons3');background-repeat: repeat;">
<div id="contactform"><form action="<?=$PHP_SELF."?".$SID?>" method="get" name="carrito">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="350">

</td>
<td rowspan="2" width="450" valign="top">

 <br />

<table width="550" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="132" align="center">Producto 1:</td>
<td width="288" align="left"><input type="text" name="item1" id="item1" size="40" value="<?php
if ($_GET['item1'] != NULL)
{
echo 
"$item1";
}
else
{
 echo 
"$Producto";
}
?>"></td>
<td width="62" align="left">Cantidad:</td>
<td width="68" align="left"><input type="text" name="cant1" id="cant1" size="5" value="<?php
if ($_GET['item1'] != NULL)
{
echo 
"$cant1";
}
else
{
 echo 
"$cant";
}
?>"></td>
</tr>
<tr>
<td width="132" align="center">Producto 2:</td>
<td width="288" align="left"><input type="text" name="item2" id="item2" size="40" value="<?php
if ($_GET['item1'] != NULL)
{

if (
$_GET['item2'] != NULL)
{
echo 
"$item2";
}
else
{
echo 
"$Producto";
}
else
{
echo 
"";
}
?>"></td>
<td width="62" align="left">Cantidad:</td>
<td width="68" align="left"><input type="text" name="cant2" id="cant2" size="5" value="<?php
if ($_GET['item1'] != NULL)
{
if (
$_GET['item2'] != NULL)
{
echo 
"$cant2";
}
else
{
echo 
"$cant";
}
}
else
{
echo 
"";
}

?>"></td>
</tr>
<tr>
<td width="132" align="center">Producto 3:</td>
<td width="288" align="left"><input type="text" name="item3" id="item3" size="40" value="<?php
if ($_GET['item2'] != NULL)
{

if (
$_GET['item3'] != NULL)
{
echo 
"$item3";
}
else
{
echo 
"$Producto";
}
else
{
echo 
"";
}
?>"></td>
<td width="62" align="left">Cantidad:</td>
<td width="68" align="left"><input type="text" name="cant3" id="cant3" size="5" value="<?php
if ($_GET['item2'] != NULL)
{
if (
$_GET['item3'] != NULL)
{
echo 
"$cant3";
}
else
{
echo 
"$cant";
}
}
else
{
echo 
"";
}
?>"></td>
</tr>
<tr>
<td width="132" align="center">Producto 4:</td>
<td width="288"><input type="text" name="item4" id="item4" size="40" value="<?php
if ($_GET['item3'] != NULL)
{

if (
$_GET['item4'] != NULL)
{
echo 
"$item4";
}
else
{
echo 
"$Producto";
}
else
{
echo 
"";
}
?>"></td>
<td width="62">Cantidad:</td>
<td width="68"><input type="text" name="cant4" id="cant4" size="5" value="<?php
if ($_GET['item3'] != NULL)
{
if (
$_GET['item4'] != NULL)
{
echo 
"$cant4";
}
else
{
echo 
"$cant";
}
}
else
{
echo 
"";
}
?>"></td>
</tr>
<tr>
<td width="132" align="center">Producto 5:</td>
<td width="288"><input type="text" name="item5" id="item5" size="40" value="<?php
if ($_GET['item4'] != NULL)
{

if (
$_GET['item5'] != NULL)
{
echo 
"$item5";
}
else
{
 echo 
"$Producto";
}
else
{
 echo 
"";
}
?>"></td>
<td width="62">Cantidad:</td>
<td width="68"><input type="text" name="cant5" id="cant5" size="5" value="<?php
if ($_GET['item4'] != NULL)
{
if (
$_GET['item5'] != NULL)
{
echo 
"$cant5";
}
else
{
 echo 
"$cant";
}
}
else
{
 echo 
"";
}

?>"></td>
 </tr>


</table>
</td>
 </tr>
 <tr>
<td valign="top"><fieldset>
<legend><font color="#FFFFFF">&sup1;Selecci&oacute;n de Producto &raquo;</font></legend>
<table border="0" cellpadding="0" cellspacing="0">
 <tr>
<td width="140">Tipo de Producto</td>
<td width="260">
<select name="tipo" id="tipo" size="1" class="input" onChange="javascript:type1();">
<option value="" selected>Seleccione Tipo de Producto</option>
<option value="Acero_Galvanizado1">Acero Galvanizado Laminas Lisas</option>
<option value="Acero_Galvanizado2">Acero Galvanizado Laminas Acanaladas</option>
<option value="Translucidos">Translucidos</option>
<option value="Panel">Panel</option>
<option value="Tejas">Tejas</option>
</select></td>
 </tr>
 <tr>
<td>Producto</td>
<td>
<select name="Producto" id="Producto" size="1" class="input" onChange="javascript:producto();">
<option value="">Seleccione Producto</option>
</select></td>
 </tr>
 <tr><td colspan="2" align="center"><br />
 <table border="0" cellspacing="0" cellpadding="0">
 <tr>
<td><label for="url">Cantidad:</label></td>
<td><input type="text" name="cant" id="cant" class="text" title="Cantidad" /></td>
 </tr>
</table>

 </td></tr>
</table>
</fieldset><br /><center>
Cotizar Otro producto:<br />
<input name="cotizar" type="radio" value="1" checked="checked" />Si
<input name="cotizar" type="radio" value="2" />No
<br /><br /><input type="submit"value="Continuar &raquo;" /></center></td>
</tr>
</table>
<br />
<div>
<center>
<table width="369" border="0" cellpadding="0" cellspacing="0">
 <tr>
<td align="left">
<table border="0" cellspacing="0" cellpadding="0">
 <tr>
<td align="center"></td>
 </tr>
</table>
</td>
 </tr>
</table>
</center>
</div>
</form></div></BODY></html>
  #5 (permalink)  
Antiguo 10/06/2009, 10:03
 
Fecha de Ingreso: junio-2009
Mensajes: 3
Antigüedad: 14 años, 10 meses
Puntos: 0
De acuerdo Respuesta: Duda en programacion

Cita:
Iniciado por pateketrueke Ver Mensaje
es igual.. asigna un name por cada submit, debe ser significativo...

y luego comparas en tu script cual boton fue presionado...

Código PHP:
if ( ! empty($_POST['agregar']))
{
 
// ...
}
elseif ( ! empty(
$_POST['cotizar']))
{
  
// ...

Te agradesco mucho me sirvio tu respuesta bastante
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 04:49.