I couldn't run your example. There are many things missing, but you gave me a valuable tip and I learned how to do.
Thanks. On 10 ago, 13:52, Marcelo Andrade <[email protected]> wrote: > On Sun, Aug 9, 2009 at 5:09 PM, Persivo Cunha<[email protected]> wrote: > > > Hi, I have two form->select and i want that after option of one be > > choice, values of other select change. > > > For example, > > > select 1: > > option: A > > option: B > > > if I choose option A, select 2 will show C and D > > if I choose option B, select 2 will show E and F > > > what should I do? > > Check the ajax helper observeField. > > An ilustrative non-tested example: > > [form view] > <?php echo $form->select('Model.select1', array('A', 'B')); ?> > <select id="select2"> > </select> > > <?php echo $form->observeField('ModelSelect1', array( > 'update'=> 'select2' > , 'url'=> '/your/action' > )); ?> > > [your controller] > function action() { > if( !empty($this->data) ) { > if( $this->data['Model']['select1'] == 'A' ) > $options= array('C', 'D'); > elseif( $this->data['Model']['select1'] == 'B' ) > $options= array('E', 'F'); > } > $this->set(compact('options')); > > } > > [you action-view] > <?php foreach($options as $option): ?> > <option id="<?php echo key($option); ?>"> > <?php echo current($option); ?> > </option> > <?php endforeach; ?> > > I hope it helps. > > Best regards. > > -- > MARCELO DE F. ANDRADE > Belem, PA, Amazonia, Brazil > Linux User #221105 > > http://mfandrade.wordpress.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
