Thanks a lot. I now got it working.
I'll also try the mootools that you suggested if I have time. =)


On Dec 1, 7:33 am, grigri <[EMAIL PROTECTED]> wrote:
> If you really want to put the javascript inline in the onClick
> attribute of each checkbox, I'd suggest rewriting the options array to
> use the alternative format, like this:
>
> $options = array();
> foreach($roles as $value => $label) {
>   $options[] = array(
>     'name' => $label,
>     'value' => $value,
>     'onClick' => 'showDiv(this)'
>   );}
>
> echo $form->input('Role', array('options' => $options, ...));
>
> But why use inline javascript? You could do this with one line of
> mootools:
>
> $$('input[id^=ModelRole][type=checkbox]').addEvent('click', showDiv);
> (replace 'Model' with the name of your model)
>
> And I'm sure it's just as easy (or easier) in jQuery or other
> frameworks
>
> hth
> grigri
>
> On Dec 1, 2:37 pm, mario <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > How can I add a javascript onclick event on a form input with multiple
> > checkbox?
>
> > I'm trying to do this using the following code..
> > <?php
> >         echo $form->input('Role',
> >                           array('type'=>'select',
> >                                 'multiple'=>'checkbox',
> >                                 'options'=>$roles,
> >                                 'label'=>'Roles:',
> >                                 'onClick'=>'showTierDiv(this)'));
> > ?>
>
> > However, when I view the source of the generated page using a browser,
> > I can see
> > that the onclick event "showTierDiv" was not included.
>
> > I also tried adding an onclick event using a form input with a
> > "single" checkbox and it works.
>
> > Here is the code:
> > <?php echo $form->input('tier',array
> > ('label'=>'Tier','type'=>'checkbox', 'onclick'=>"showDiv(this)")); ?>
>
> > Is there any way to add onclick event on a form input with multiple
> > checkbox?
> > If none, are there any workarounds for this?
>
> > Thanks,
>
> > Mario
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to