Saturday, March 28, 2009

getSelectionId error

Hello all,

I'm building a search form using the autocomplete helper. i'm doing
the search after some text and everithing is working fine, but i want
the input element, on submit, to submit the id of the specific text
element from the databse. i found here an example to add
afterUpdateElement => getSelectionId, in the options array of the
autocomplete method. then i define this function to get the id of the
li element and transmit it to the input text, but i'm still getting an
error, telling me getSelectionId function is not defined. here's the
code:

<form id="search_by_name_form" action="" method="post" style="display:
none;">
<p><?php echo $ajax->autoComplete
( 'Contact.lastname', array( 'controller' => 'contacts', 'action' =>
'autoCompleteByName' ), array( 'afterUpdateElement' =>
'getSelectionId' ) ); ?></p>
</form>

<script type="text/javascript">
function getSelectionId(text, li) {
alert (li.id);
document.getElementById('ContactLastname').value=li.id;
}
</script>


i don' know what's the problem and i can't find anything in the
manual. does anyone sees the problem?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: