Wednesday, December 7, 2011

Get a value of a select using JS helper.

I'm trying to build a simple dynamic state / city dropdown menu that
pulls from my database... Everything is working except I cannot get
the value of the "#divstate" to further populate the city... If I
manually enter a # into 'param1', it gets the correct information, and
correctly updates the "#divcity"

Let me know if you need more code, thanks!


<?php

echo $this->Form->create('newForm');
echo $this->Form->input('teacher', array ('type'=>'select', 'id' =>
'divstate', 'options' => $states ));
echo $this->Form->input('classes', array ('type'=>'select', 'id' =>
'divcity', 'empty' => '-- Pick a state first --'));
echo $this->Form->end();
?>


<?php

$this->Js->get('#divstate')->event('change',
$this->Js->request(array(
'action' => 'getcities', 'param1'), array(
'async' => true,
'update' => '#divcity',
'data' => '$("divstate").serialize()',
'dataExpression' => true
)));


?>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate