Forum: Ruby on Rails auto_complete_on_select don't work correctly

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1ed2ce79377a1fb594755273d7e972ba?d=identicon&s=25 Max Baldo (baldomaxi)
on 2006-03-29 17:02
Hi, i hope that's the correct place for this question.
I must update two input text from autocomplete. The list is, for
exemple:

<ul>
<li>
  <span class="comune_name">pippo</span>
  <span class="lat" style="display:none">1.2</span>
  <span class="long" style="display:none">3.0</span>
</li>
</ul>

I want  in <input id="inputlat" type="text" value="-" /> the value 1.2
and in <input id="inputlong" type="text" value="-" /> the value 3.0

I have used auto_complete_on_select but not work.Any suggestion?

The code is:

function auto_complete_on_select(element, selectedElement)
{
    document.getElementById('inputlat').value =
selectedElement.childNodes.item.getElementsByTagName('span')[0].innerHTML;
	document.getElementById('inputlong').value =
selectedElement.childNodes.item.getElementsByTagName('span')[1].innerHTML;
}



        <input name="comune" class="autocomplete" id="autocomplete"
size="20" type="text" onkeyup="new Ajax.Autocompleter('autocomplete',
'autocomplete_choices', 'list.php',
                        {minChars: 2,afterUpdateElement:
auto_complete_on_select} );"/>

        <br/> lati: <input id="inputlat" type="text" value="-" />
        <br/> long:  <input id="inputlong" type="text" value="-" />


Thanks in advance
max
This topic is locked and can not be replied to.