Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/04/2009, 19:16
camirz
 
Fecha de Ingreso: abril-2009
Mensajes: 1
Antigüedad: 15 años
Puntos: 0
validar checkbox multiple

De antemano gracias por la colaboraciòn que me puedan brindar.

Resulta que he venido incursionando en este tema ultimamente y quisiera saber como debo hacer para que en el formulario que he creado a parte de validarme los campos select puede validar campos checkbox a partir de un recordset automatico el cual es generado de acuerdo a las tablas donde se almacena cierta informacion.

he aquí el código que he venido trabajando, agradezco me puedan colaborar, ya que es urgente....GRACIAS

<?php
if($_GET['carga']=='1')
{
$campos = " trans, capaci, serad, sercap, fechades, usuario, fechamod";
$tablas = "consolidado ";
$valores="'".$_POST['vehi']."','".$_POST['cap']."','".$_POST['serad']."','".$_POST['ca']."','".$_POST['fechades']."','".$my->username."','".$fecha_mod."'";

if($query->insert($tablas, $campos, $valores))
{
?>
<script language="javascript" type="text/javascript">
alert("la consolidación de solicitudes fue cargada con exito");
location.href=('index.php?option=com_pot&op=4&Item id=32');
</script>
<?php
}
else
{
echo mysql_error();
}
}
?>
<script language="javascript">
function validate()
{
var vehi=document.getElementById("vehi").value;
var cap=document.getElementById("cap").value;
var serad=document.getElementById("serad").value;
var ca=document.getElementById("ca").value;
var fechades=document.getElementById("fechades").value ;

var error="";
if(serad.length ==0 && ca.length ==0)
{ if(vehi.length ==0 || cap.length ==0)
error+="Debe Seleccionar Tipo de Vehículo y Capacidad\n";
}
else
{
if(serad.length ==0 || ca.length ==0)
error+="Debe Seleccionar Servicio Adicional y Capacidad\n";
}
if(fechades == "" )
error+="Debe Diligenciar la Fecha de Despacho\n";
if(error!="")
alert(error);
else
{
document.pot.action='index.php?option=com_pot&op=4 &Itemid=32&carga=1';
document.pot.submit();
}
}
</script>

<form method="post" name="pot1" id="pot1">
<table class="cpd" border="0" cellspacing="5" cellpadding="0" align="center">
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="3%" rowspan="6">&nbsp;</td>
<td><div><span style="font-size: 9pt; font-family: Arial, Helvetica, sans-serif">Bienvenido <strong><font color="#D40000"> <?php echo $usuario; ?></font></strong>,</span></div></td>
<td width="3%" rowspan="6">&nbsp;</td>
</tr>
<tr>
<td><div align="center"><strong>CONSOLIDAR SOLICITUDES</strong><BR /><BR /></div></td>
</tr>
<tr>
<td>
<table width="200" border="1" align="center" class="cpd">
<tr>
<td width="84" class="cpd1"><div align="center"><strong>Solicitud No.</strong></div></td>
<td width="100" class="cpd1"><div align="center"><strong>Fecha Compromiso</strong></div></td>
<td width="80" class="cpd1"><div align="center"><strong>Peso</strong></div></td>
<td width="148" class="cpd1"><div align="center"><strong>Origen</strong></div> </td>
<td width="146" class="cpd1"><div align="center"><strong>Destino</strong></div> </td>
</tr>


<?php
$campos = "p.id, p.fechacomp, p.ton, co.descripcion as ciudad, cd.descripcion as ciudad1";
$tablas = " pot p INNER JOIN ciudad co on p.ciudad = co.id INNER JOIN ciudad cd on p.ciudad1 = cd.id ";
$arg = " estado=1 || estado=4 ";
$res_pro=$query->select( $campos, $tablas, $arg);

while($con_res=mysql_fetch_assoc($res_pro))
{
?>
<tr>
<td width="84" height="30"><div align="center">
<input name="idpedido" type="checkbox" value="<?php echo $con_res['id']; ?>" /><font size="-0.8"><?php echo $con_res['id']; ?></font></div>
</td>
<td width="100">
<div align="center">
<input type="text" name="fechacomps" size="10" style="font-size:10px;" value="<?php echo $con_res['fechacomp']; ?>" readonly="readonly" />
</div>
</td>
<td width="80">
<div align="center">
<input type="text" name="tonn" size="2" style="font-size:10px;" value="<?php echo $con_res['ton']; ?>" readonly="readonly" /> Toneladas
</div>
</td>
<td width="148">
<div align="center">
<input type="text" name="ciudadd" style="font-size:10px;" value="<?php echo $con_res['ciudad']; ?>" readonly="readonly" />
</div>
</td>
<td width="146">
<div align="center">
<input type="text" name="ciudad11" style="font-size:10px;" value="<?php echo $con_res['ciudad1']; ?>" readonly="readonly" />
</div>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<table width="650" border="1" align="center" class="cpd1">
<tr>
<td width="100" class="cpd1"><div align="center"><strong>Veh&iacute;culo</strong></div></td>
<td width="100" class="cpd1"><div align="center"><strong>Capacidad</strong></div></td>
<td width="123" class="cpd1"><div align="center"><strong>Fecha Despacho:</strong></div></td>
</tr>
<tr>
<td width="144"><div align="center">
<?php
$campos = "id,descripcion, capaci";
$tablas = " tipo_vehi ";
$arg = " id != '0' and id!='".$_POST['vehi']."' ";
$res_pro=$query->select( $campos, $tablas, $arg);

$campos = "id,descripcion, capaci";
$tablas = " tipo_vehi ";
$arg = " id = '".$_POST['vehi']."' ";
$res_pro2=$query->select( $campos, $tablas, $arg);
if($con_res2=mysql_fetch_assoc($res_pro2))
?>
<select name="vehi" id="vehi" class="inputbox3" onChange="document.pot1.action='index.php?option=c om_pot&op=4&Itemid=32'; pot1.submit();" ><option selected="selected" value="">Ninguno..</option>
<?php
if($_POST['vehi']!='')
{
?>
<option value="<?php echo $con_res2["id"]; ?>" selected="selected"><?php echo $con_res2["descripcion"]; ?> </option>
<?php
}
?>
<?php
while($con_res=mysql_fetch_assoc($res_pro))
{
?>
<option value="<?php echo $con_res["id"]; ?>"><?php echo $con_res["descripcion"]; ?></option>
<?php
}
?>
</select></div></td>
<td width="119"><div align="center"><select name="cap" id="cap" class="inputbox3" ><option selected="selected" value="">Ninguno..</option>
<?php
if($_POST['vehi']!='')
{
?>
<option value="<?php echo $con_res2["id"]; ?>" selected="selected"><?php echo $con_res2["capaci"]; ?> </option>
<?php
}
?>
<?php
while($con_res=mysql_fetch_assoc($res_pro))
{
?>
<option value="<?php echo $con_res["id"]; ?>"><?php echo $con_res["capaci"]; ?></option>
<?php
}
?></select></div></td>
<td><div align="center">
<?php
$campos = "id,descripcion";
$tablas = " adicional ";
$arg = " id != '0' and id!='".$_POST['serad']."' ";
$res_pro=$query->select( $campos, $tablas, $arg);

$campos = "id,descripcion";
$tablas = " adicional ";
$arg = " id = '".$_POST['serad']."' ";
$res_pro2=$query->select( $campos, $tablas, $arg);
if($con_res2=mysql_fetch_assoc($res_pro2))
?>
<select name="serad" id="serad" class="inputbox3" onChange="document.pot1.action='index.php?option=c om_pot&op=4&Itemid=32'; pot1.submit();" ><option selected="selected" value="">Ninguno..</option>
<?php
if($_POST['serad']!='')
{
?>
<option value="<?php echo $con_res2["id"]; ?>" selected="selected"><?php echo $con_res2["descripcion"]; ?> </option>
<?php
}
?>
<?php
while($con_res=mysql_fetch_assoc($res_pro))
{
?>
<option value="<?php echo $con_res["id"]; ?>"><?php echo $con_res["descripcion"]; ?></option>
<?php
}
?>
</select></div></td>
<td><div align="center">
<?php
$campos = "id,descripcion";
$tablas = "cap_adicional ";
$arg = " id!='".$_POST['ca']."' and concatena ='".$_POST['serad']."' ";
$res_pro=$query->select( $campos, $tablas, $arg);

$campos = "id,descripcion";
$tablas = " cap_adicional ";
$arg = " id = '".$_POST['ca']."' and concatena ='".$_POST['serad']."' ";
$res_pro2=$query->select( $campos, $tablas, $arg);
if($con_res2=mysql_fetch_assoc($res_pro2))
?>
<select name="ca" id="ca" class="inputbox3" onChange="document.pot1.action='index.php?option=c om_pot&op=4&Itemid=32'; pot1.submit();"><option selected="selected" value="">Ninguno..</option>
<?php
if($_POST['ca']!='')
{
?>
<option value="<?php echo $con_res2["id"]; ?>" selected="selected"><?php echo $con_res2["descripcion"]; ?> </option>
<?php
}
?>
<?php
while($con_res=mysql_fetch_assoc($res_pro))
{
?>
<option value="<?php echo $con_res["id"]; ?>"><?php echo $con_res["descripcion"]; ?></option>
<?php
}
?>
</select></div></td>
<td>
<div align="center">
<input class="inputbox3" name="fechades" id="fechades" size="10" type="text" value="<?php echo $_POST['fechades']; ?>"readonly="readonly">
<script language="JavaScript" type="text/javascript">
Calendar.setup({inputField : "fechades", ifFormat : "%Y-%m-%d", daFormat : "%A, %B %d, %Y",button : "fechades" });
</script>
</div>
</td>
</tr>

</table><br /><br />
<div align="center">
<input class="inputbox3" id="aceptar2" type="button" name="aceptar2" onclick="validate()" value="Guardar" /></div>
</td>
</tr>
</table>
</form>