Monday, September 5, 2011

Re: dropdown onchange send ajax submit

You are nearly there as you've tried adding an onChange event to
DealQuantity.

Problem is 'onchange'=> 'ajax submit' isn't going to do anything as
it's not a valid javascript call. It looks as though you've used the
$ajax->submit() function from the Ajax Helper and assumed you can type
in a similar string into your field's onchange attribuite. If you have
FireBug or something similar enabled (and you should if doing any
JavaScript work) then you would see an error when that onChange event
fires.

Hint: look at the code $ajax.submit() is outputting and you should
find your answer in there.

HTH, Paul.
@phpMagpie

On Aug 31, 6:34 am, abhimanyu bv <vmabhi...@gmail.com> wrote:
> hi all,
> i created a form(below).
> <?php
>                                 echo $this->Form->create('Deal');
>                                 echo $this->Form->hidden('deal_id', array('value' =>
> $deal['deal_id']));
>
>                                 $options = array(1 => 1,2 => 2,3 => 3,4 => 4,5 => 5);
>                                 echo $this->Form->input('quantity', array( 'type' => 'select',
> 'label' => '' , 'value' => $deal['value'] ,
>                                                                                 'onchange'=> 'ajax submit','options' => $options));
>                                 echo $ajax->submit('update', array('url'=>
> array('controller'=>'deals', 'action'=>'cart'), 'update' =>
> 'shoppingcart'));
>                                 echo $this->Form->end();
> ?>
> what i done is there is a select box and update button. If i select a
> value in dropdown and clicks submit,then ajax method is working, but i
> dont want to give update button in that form,instead i want to have an
> onchange event for the dropdown, so that if user selects a value, the
> form is updated. how to do this?
> If i am giving the onchange as this.form.submit(), then it is taking
> as normal request. Is there any simple solution to this/

--
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

No comments: