Try using the built in ajax helper.  This is how I did one of my
fields:

echo "<div class=\"optional\"><span class=\"userRegisterLabel\"><label
for=\"UserMiddleinitial\">Middle Initial:&nbsp;</label></span><span
class=\"userRegisterField\">" . $html->input('User/middleinitial',
array (
    'size' => 30
))."</span><div id=\"userRegisterMiddleinitial\"></div></div>";

echo $html->tagErrorMsg('User/middleinitial', 'The middle initial
should be one letter and may have a period.');

// HERE HERE HERE
echo $ajax->observeField('UserMiddleinitial', array (
    'url' => 'check_registration_form/middleinitial/',
    'update' => 'userRegisterMiddleinitial',
    'frequency' => 0.001, <----Use 0.001 here so IE picks this up, if
set to 0 or has none, IE doesn't update. -->
    'loading' =>
"document.getElementById('userRegisterMiddleinitial').style.display =
'block'",
    'loaded' =>
"document.getElementById('userRegisterMiddleinitial').style.display =
'block'"
    ));
// END END END
On Jun 18, 2:54 pm, TheTorst <[EMAIL PROTECTED]> wrote:
> Hi, I'm trying to create a form were a select input calls Ajax.Update
> onChange. I'm starting to get frustrated since my ajax function seems
> to be completely dead, nothing happens onChange.
>
> Here are some snippets of my code:
> --------------index.thtml--------------
> <?php
> echo $form->create('User', array('action' => '/addPurchase'));
> echo $form->input('Purchase/group_id', array('label' => 'Select group:
> ', 'onchange' => "new Ajax.Updater('checkboxes', '/users/
> updatecheckboxes/', {asynchronous:true, evalScripts:true});", 'empty'
> => false));?>
> <div id="checkboxes">
> <?php
> foreach ($groupmembers as $member){
>     echo $form->input('checkbox'.$member['id'], array(
>         'label' => $member['username'],
>         'type' => 'checkbox',
>         'empty' => false));}?>
>
> </div>
> <?php
> echo $form->Submit('Submit',array('div'=>false,'id'=>"button"));
> echo $form->end(Null);
> --------------end of index.thtml--------------
> --------------users_controller.php--------------
> ...
> var $helpers = array('Form','Ajax','Javascript','Html');
> ...
>     function updatecheckboxes(){
>         $myGroup = $this->User->Group->findById('2');
>         $this->set('groupmembers', $myGroup['User']);
>         $this->render('checkboxes','ajax');
>     }
> ...
> --------------end of users_controller.php--------------
> --------------checkboxes.thtml--------------
> <?php
> foreach ($groupmembers as $member){
>     echo $form->input('checkbox'.$member['id'], array(
>         'label' => $member['username'].'1',
>         'type' => 'checkbox',
>         'empty' => false));
>     echo 'hello';}?>
>
> --------------end of checkboxes.thtml--------------
>
> My page head looks like this:
> <head>
> <script src="javascripts/prototype.js" type="text/javascript"></
> script>
> <script src="javascripts/scriptaculous.js" type="text/javascript"></
> script>
> <title>Users</title>
> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
> <link rel="stylesheet" type="text/css" href="/cakeMoney/css/
> cake.default.css" />
> </head>
>
> I'm starting to give up, I simply cant see what I'm doing wrong.
> Please help.
> Thanks
> -Dan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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