views:

54

answers:

2

I'm using Jquery Autocomplete based on: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/. I am able to select a value from the textbox and add it to a list as in the example. Is it possible to add the selected value to a hidden field? For example <input type='hidden' value='value 1,value 2, value 3' name="SelectedValue" id="SelectedValue"/>

A: 
$('input#suggest').result(function(event, data, formatted) {
   $("#SelectedValue").val( $("#SelectedValue").val() + "," data );
});

Look over autocomplete documentation for details

ShiVik
A: 

To add more than one value to a hidden field:

var hdnValue = $('hdnFieldName').val();
$('hdnFieldName').val(hdnValue +','+selectedValue);

Have a look at string.join as well.

cofiem