I want to make form autosubmit when radio button value is selected.
Right now I'm using separate submit button, and code like this:
echo $ajax->form('/ratings/rate/'.$photo_id, 'POST',
array( 'id' => 'rate_form_'.$photo_id, 'update'=>'rating_'.
$photo_id ));
echo $html->radio('Ratings/rate',
array('1'=>'1', '2'=>'2',
'3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '9'=>'9',
'10'=>'10'));
echo $html->submit('vote', array( 'id' => 'rate_form_'.$photo_id));
echo '</form>';
Which gives me:
<form id="rate_form_4463" action="/ratings/rate/4463" onsubmit="return
false;" method="post">
<script type="text/javascript">
Event.observe('rate_form_4463',
'submit', function(event){ new Ajax.Updater('rating_4463',
'/ratings/rate/4463',
{asynchronous:true, evalScripts:true,
parameters:Form.serialize('rate_form_4463'),
requestHeaders:['X-Update', 'rating_4463']}) }, false);
</script>
<input name="data[Ratings][rate]" id="rate_1" value="1" type="radio">1
<input name="data[Ratings][rate]" id="rate_2" value="2" type="radio">2
...
<input id="rate_form_4463" value="vote" type="submit"></form>
What should I change? I was trying to pass htmlattributes to radio
buttons with "onclick=this.form.submit();" but ajax didn't catch it
because he is observing different ID (rate_form_4463) - how to obey
this without generating multiple radio buttons with the same ID which
is a error situation as I guess.
Sorry for my english :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment