Jeremy,

Thanks very much for the info.  I will try that as soon as I can.  I
was also wondering if you had any info on some other things I wanted
to do with the field.  I want to be able to arrow down and select an
item.  Can i use any control I want in the autocomplete.thtml?  Also I
wanted to create a new entry if they don't select one from the list.
So if they type in a company it is not in the list, when they hit tab
or enter I want to give them the option to insert the company into the
table.  If you have any info on that I would really appreciate it.

thanks very much for all the help

On Mar 28, 2:52 am, Jeremy Pointer <[EMAIL PROTECTED]> wrote:
> Below is an almost exactly similar question and my previous answer. HTH
>
> robert.fulcher wrote:
> > I want to use the autocomplete componenet and was wondering how to use
> > the options.  I want to use it with a lookup field.  I have a contact
> > that I want to assign a company to.  I have it where I can lookup the
> > company by name in the autocomplete field.  I need to assign a value
> > of the id from the company to a field to be submitted to the
> > controller.  Anyone know how to do that.
>
> > Thanks
>
> This is from something I did, No change in the controller but I've
> modified the below views, the key is to set the user id as the id of the
> <li> tag in autocomplet, and then have
> a 'user_id' input and a touch of  javascritpt in the send view to update
> the id field, then set the 'afterUpdateElement' option in
> $ajax->autocomplete()
>
> autocomplete.thtml:
>
> <ul>
> <?php foreach($users as $user): ?>
> <li id="<?php echo $user['User']['id']; ?>"><?php echo
> $user['User']['username'].' ('.$user['User']['fname'].'
> '.$user['User']['lname'].')'; ?></li>
> <?php endforeach; ?>
> </ul>
>
> send.thtml:
>
> <form action="<?php echo $html->url('/messages/send'); ?>" method="post">
>
> <?php echo $html->input('Message/user_id'); ?>
> <script type= 'text/javascript'>
>     function getSelectionId(text, li) {
>         alert(li.id);
>         document.getElementById('MessageUserId').value=li.id;
>     }
> </script>
> <?php echo $ajax->autocomplete('Message/user','/contacts/autocomplete',
>                 array('size' => 40, 'afterUpdateElement'=>'getSelectionId'
>                 )
>             ); ?>
>
> <?php echo $html->textarea('Message/message', array('cols' => '60',
> 'rows' => '10')); ?>
> <div class="submit">
>     <?php echo $html->submit('Send');?>
> </div>
> </form>
>
> HTH
> JermWorm
>
>
>
> Mike Griffin wrote:
> > On 3/16/07, fredBH <[EMAIL PROTECTED]> wrote:
>
> >> can you post the code ?
>
> > Sure, here is the sutocomplete.thtml file.  It returns the username
> > and then the full name in brackets
> > <ul>
> > <?php foreach($users as $user): ?>
> > <li><?php echo $user['User']['username'].' ('.$user['User']['fname'].'
> > '.$user['User']['lname'].')'; ?></li>
> > <?php endforeach; ?>
> > </ul>
>
> > The form is in send.thtml
>
> > <form action="<?php echo $html->url('/messages/send'); ?>" method="post">
> > <?php echo $ajax->autocomplete('Message/user',
> > '/Messages/autocomplete', array('size' => 40)); ?>
>
> > <?php echo $html->textarea('Message/message', array('cols' => '60',
> > 'rows' => '10')); ?>
> > <div class="submit">
> >     <?php echo $html->submit('Send');?>
> > </div>
> > </form>
>
> > And the autocomplete function from the messages controller:
> > function autocomplete() {
> >     $this->set('users', $this->User->findAll(array('User.username' =>
> > 'LIKE '.$this->data['Message']['user'].'%'), array('User.username',
> > 'User.fname', 'User.lname', 'User.id'), 'username DESC',null, null,
> > 0));
> >     $this->layout = "ajax";
> > }
>
> > So the function returns the User.id but I cant see how to pass that to
> > the view and back again.
>
> > Mike.
>
> > >
> --
> */Jeremy Pointer/*
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>  jerm.vcf
> 1KDownload


--~--~---------~--~----~------------~-------~--~----~
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