Hi everyone.
Been working on a simple field that would get Product Accessories.
It's been a real challenge but I think 60% done.
Only problem is updating the hidden input field.

I have this code:

<input name="" type="text"  id="accessory_field"
        param_name= "search_accessories"
         autocomplete ="off"
    <input name="product[product_accessory_ids][]" type="hidden"  
        param_name= "product_id"
        autocomplete ="off"
<div class="autocomplete" id="accessory_auto_complete"></div>

<span id="indicator" style="display: none">
  <img src="/images/indicator.gif" alt="Working..." />
<script language="javascript">
 new Ajax.Autocompleter('accessory_field', 'accessory_auto_complete', 
  tokens: ',',
  indicator: 'indicator',
  paramName: 'search_accessories',
  afterUpdateElement: getAccessoryId
 function getAccessoryId(text, li){
   $('product_accessory_id').value = li.id;

The output in /admin/products/get_accessories
is something like this:

<ul class="autocomplete_list">
<li id="1239183629">Term 1</li>
<li id="1239183630">Term 2</li>

It successfully saves the id of the first term, but not for other terms 
(accessories search by user through autocomplete).
Basically what is needed is code to add the id to the hidden input value.

If it's much more difficult to achieve through scriptaculous, my last 
option is to restructure the database to make saving simple.
But that's probably a bad idea.
Any guru can probably help with this problem. I'm so newbie in javascript.

thanks in advance...

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to