如何附加从自动完成js中选择的值

时间:2015-07-07 12:40:07

标签: javascript jquery autocomplete

我需要什么

  • 我需要在自动填充的html选定值中附加值

                   $('.autocomplete_ind').autocomplete({
                    lookup: industrys,
                    onSelect: function(suggestion) 
                    {
                        console.log(suggestion);

                        var thehtml = '<strong>industry name:</strong> ' + suggestion.name + ' selected<br> <strong>'+ suggestion.id+'</strong>';
                        $('#outputcontent').append(thehtml);
                        $(this ).attr( "value",  suggestion.value );
                   }

html元素

 <input type="text"  autocomplete="off"  onChange="make_url();"
             id="industry_name"  class="biginput autocomplete_ind"  name="allindustry"  value="">
  • 我试过
  • 两种解决方案都不起作用。
  • 我喜欢自动填充值中的选择值应该是视图查看源,否则值保持为空。
  • document.getElementsByName(&#39;全部行业&#39;)[0] = .placeholder suggestion.value;
  • $(this).attr(&#34; value&#34;,suggestion.value);它就像追加值属性值=&#34; somevalue&#34;
  • 但是在观看源值=&#34;&#34;空的。
  • 欢迎任何建议

0 个答案:

没有答案