- $(".autocomplete").each(function() {
- $(this).autocomplete("search/autocomplete/"+this.name,{selectOnly:1,formatItem:format_autocomplete,matchSubset:0,width:$(this).width()});
- });
+ $(".autocompleteTarget").hide();
+ $(".autocomplete").show().each(function() {
+ targeted = $("../.autocompleteTarget",this)[0];
+ if (targeted && targeted.value) {
+ me = $(this);
+ $.get('search/list/'+ targeted.name +'/'+targeted.value, {},function(textValue) {
+ me.attr('value', textValue);
+ me.addClass('hidden_valid');
+ });
+ }
+ $(this).autocomplete("search/autocomplete/"+this.name,{
+ selectOnly:1,
+ formatItem:format_autocomplete,
+ field:this.name,
+ onItemSelect:select_autocomplete(this.name),
+ matchSubset:0,
+ width:$(this).width()});
+ });
+ $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); });
+ $(".autocompleteToSelect").each(function() {
+ var fieldName = $(this).attr('href');
+ $(this).attr('href','search/list/'+fieldName).click(function() {
+ var oldval = $("input.autocompleteTarget[@name='"+fieldName+"']")[0].value;
+ $(".autocompleteTarget[@name='"+fieldName+"']").parent().load('search/list/'+fieldName,{},function(selectBox) {
+ $(".autocompleteTarget[@name='"+fieldName+"']").remove();
+ $(".autocomplete[@name='"+fieldName+"Txt']").remove();
+ $("select[@name='"+fieldName+"']").attr('value', oldval);
+ });
+ return false;
+ });
+ });