well I have a main_categories and sub_categories table.
I have to take main_cat tbl data in 1 dropdown n on change of it
depending upon the cat_id select data from sub_categories table
and display in a drop down.
Tbl schema is:
main_categories(main_category_id,main_category, type, active)
sub_categories(sub_category_id, sub_category, main_category_id, type,
active);
Thanks in Advance
On Apr 2, 9:07 pm, cricket <zijn.digi...@gmail.com> wrote:
> First off, you can save yourself the foreach loop by using
> find('list'), which will give you an array you can pass directly to
> the select() method.
>
> Anyway, this depends on how you're using javascript. If you happen to
> be using jQuery, have a look at the $.ajax() function. Figure out what
> the generated ID of the select list is and do something like this:
>
> $('#theSelectID').change(function()
> {
> $.ajax({
> url: '/controller/action/'+$(this).val(),
> cache: false,
> success:
> function(html)
> {
> $('#theSelectID').after(html);
> }
> });
>
> });
>
> Create an action in your controller that accepts a Supplier.id and
> fetches a list. Use RequestHandler to test that it's an AJAX request.
> Populate the new select list in your view. That will be passed back to
> the $.ajax() function.
>
> The way you place the returned html into the document will vary
> according to your layout, of course.
>
> On Apr 2, 3:35 am, Ambika Kulkarni <ambikakulkarn...@gmail.com> wrote:
>
> > Hi there,
>
> > I'm pretty new to CakePHP. I have a drop down menu, in which the data
> > comes from DB. Following is the code for that.
> > In Controller file
> > function step_one(){
> > $suppliers = $this->Supplier->find('all', array('fields' =>
> > 'Supplier.name'));
> > $this->set('suppliers',$suppliers);
>
> > }
>
> > View file
>
> > $a = array();
> > $i=1;
> > foreach( $suppliers as $supplier ):
> > $a[$i] = $supplier['Supplier']['name'];
> > $i++;
> > endforeach;
> > echo $form->input('Supplier ', array('options' => $a));
>
> > This creates a drop down menu. On change I want to have another drop
> > down in which the data is fetched from DB.
>
> > Thanks In advance
> > :)
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
To unsubscribe, reply using "remove me" as the subject.
No comments:
Post a Comment