I don't think the class option works for multiple checkboxes.
-- What you can do is specify a div and work off of that (you can also reduce your js code):
echo $this->Form->input("Country", array("options" => $viewData["countryList"], "multiple" => "checkbox", "onclick" => "resetSelectAll();" , "div" => "countries" , "name" => "selectedId"));
On Friday, November 15, 2013 1:05:52 AM UTC-5, Sally wrote:
$('#selectall').click(function () {
var checked = $(this).is(':checked');
$('.countries input[type=checkbox]').each(function(){
$(this).prop('checked', checked);
});
});
On Friday, November 15, 2013 1:05:52 AM UTC-5, Sally wrote:
I need help with this. I'm creating a checkbox to select or deselect the country options. Please help to give some clues and explaination. I'll be very grateful. Thanks in advance.Below are the code:Location: View/country/add.ctp file<script type="text/javascript">$(document).ready(function () {$('#selectall').click(function () {var checked = $(this).is(':checked');$('.selectedId').each(function () {var checkBox = $(this);console.debug(checkBox);if (checked) {checkBox.prop('checked', true);}else {checkBox.prop('checked', false);}});});});</script><div><?php echo $this->Form->create('Showcase'); ?> <fieldset><legend><?php echo __('Add Showcase Product'); ?></legend><?phpecho $this->Form->input('p_start', array('label' => 'Start Date'));echo $this->Form->input('p_end', array('label' => 'End Date'));echo $this->Form->input('priority', array('label' => 'Priority'));echo $this->Form->input('Select all Country', array("type" => "checkbox", 'id'=>'selectall'));echo $this->Form->input("Country", array("options" => $viewData["countryList"], "multiple" => "checkbox", "onclick" => "resetSelectAll();" , "class" => "selectedId" , "name" => "selectedId"));?></fieldset><?phpecho $this->Form->end(__('Submit')); echo $this->Html->link('Back', array('action' => 'listShowcases'));?></div>
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment