echo $form->input('User.name', array('onfocus' => 'CheckCheckBox
(this.form)'));

On Aug 27, 9:18 pm, fabio <[email protected]> wrote:
> Dear all,
>
> i'm a CakePHP newbie and i'm looking for some help regarding a
> particular use of checkboxes in a form.
>
> Basically i've got a check-boxes-section in the form of a baked
> edit.ctp, called with a basic
>
> echo $form->input('Amenity', array( 'type' => 'select', 'multiple' =>
> 'checkbox' ));
>
> The models refers to a join table with an additional field 'specify':
>
> CREATE TABLE IF NOT EXISTS `amenities_properties` (
>   `id` int(11) unsigned NOT NULL auto_increment,
>   `property_id` int(11) NOT NULL,
>   `amenity_id` int(11) NOT NULL,
>   `specify` varchar(100) NOT NULL default 'yes',
>   PRIMARY KEY  (`id`)
> );
>
> The idea is to set values like this:
>
> 'no' ....................if unchecked
> 'yes' ..................if checked
> 'whatever'........... if checked and a string 'whatever' is inserted
>
> In other words I need to associate to each checkboxes an additional
> input text field to be eventually filled only if the checkboxes are
> previously checked
>
> I've found what it seems a perfect solution for this, but now I need
> some help to implement it in CakePHP terms.
>
> Here it is:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> TR/html4/strict.dtd">
> <html>
>         <head>
>                 <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
>                 <title>Test Checkbox</title>
>                 <script type="text/javascript">
>                         function CheckCheckBox(frm)
>                         {
>                         if (!frm.CheckThis.checked)
>                         frm.CheckThis.focus()
>                         }
>                 </script>
>         </head>
>         <body>
>          <form>
>                 <p><input type="checkbox" name="CheckThis">
>                 To insert your name check the box.</p>
>                 <p>
>                 Name:
>                 <input type="text" name="UserName" onfocus="CheckCheckBox
> (this.form)"></p>
>      </form>
>         </body>
> </html>
>
> (see it in action here:http://www.html.it/articoli/1756/esempio.html
> )
>
> How you can see, the javascript function allows the user to input an
> alternative value to yes/no only if the checkbox is previously checked
>
> So the point is:
> how to get done this behaviour togheter with CakePHP default Form
> Helper ?
> Do you think it's possible somehow or another approach would be better
> to achieve the same result ?
>
> Thanks a lot in advance for some suggestions
>
> Best regards
>
> fabio
--~--~---------~--~----~------------~-------~--~----~
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