开发者

Passing ID value in autocomplete in Scriptaculous

I have the scriptaculous autocompleter working. It pops up the data and I can select it, but it does not transfer the ID number in the form I'm using. I just cannot get the ID number. I can show the ID number on the screen using the following command:

alert (li.id);

I have used the following but no luck:

document.getElementById('inv_id').value=li.id; 

and

$("#inv_id").val(li.id);

How do I pass that ID number to a value in the form? Here is the form code...

<form  action="page2.php" method="post" name="Add_Form">
<input type="hidden" name="inv_id" value="0">
&l开发者_开发百科t;input type="text" id="autocomplete" name="autocomplete_parameter"/>
<div id="autocomplete_choices" class="autocomplete"></div>
</form>

<script type="text/javascript"> 

new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "ajax_inv.php", {
  afterUpdateElement : getSelectedId
});

function getSelectedId(text, li) {

  alert (li.id); 
  document.getElementById('inv_id').value=li.id; 

or

  $("#inv_id").val(li.id);

}

</script>


Where is the inv_id field? Make it a hidden input if you don't have it existing already, then document.getElementById('inv_id').value=li.id; should work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜