Ver Mensaje Individual
  #8 (permalink)  
Antiguo 12/09/2008, 14:23
Avatar de .php
.php
 
Fecha de Ingreso: julio-2006
Mensajes: 481
Antigüedad: 17 años, 9 meses
Puntos: 5
Respuesta: Como cargar un combo a partir de una seleccion de checkbox

ya mira hice un ejemplo pequeño. en kumbia, te puede servir como guía


primero
tu controlador llamado tabla_controller.php

Código PHP:
<?php
class TablaController extends ApplicationController {
    function 
index(){
        unset(
$this->arreglo);
        
$db     =    db::raw_connect();
        
$sql    =    "SHOW FIELDS FROM vacunas";    
        foreach(
$db->in_query($sql) as $item){
            
$this->arreglo[]    .= $item["Field"];
        }
        
$db->close();
    }
    function 
combos(){
        unset(
$this->arregloB);
        foreach(
$this->request("pos") as $arreglo){
             
$this->arregloB[] .= $arreglo;
         }
    }
}
?>
ahora debes tener 2 vistas
1 para mostrar los check y otra para el select

view index.phtml

Código PHP:
<?= form_tag("tabla/combos"?>
<table>
<? for($i=0;$i<count($arreglo);$i++){ ?>
<tr>
    <td><?= checkbox_field_tag("pos[$i]""value: $arreglo[$i]"?></td>
    <td><?=  $arreglo[$i?></td>
</tr>
<??>
<tr>
<td colspan="2"><?= submit_tag("aceptar"?></td>
</tr>
</table>
<?= end_form_tag() ?>
view combos.phtml

Código PHP:
<?= select_tag("campos"?>    
<?= option_tag("0""Seleccione una...""selected: true"?>
<?  
for($i=0;$i<count($arregloB);$i++){ ?>
    <?= option_tag($i$arregloB[$i]) ?>
<? 
?>
</select>

esto lo puedes combinar con ajax y quedara super bien.


suerte!!!
__________________
~~[FiDeLio]~~