[英]How to add search result to textbox when clicked in (like Multi-select boxes (pillbox))
i have been stuck with this, when i click the first button then the second button i need the value to be appended with each other not overwritten.我一直坚持这一点,当我单击第一个按钮然后单击第二个按钮时,我需要将值相互附加而不被覆盖。
you can find below the image link.您可以在图片链接下方找到。 thank you
谢谢你
<script type="text/javascript">
$(document).ready(function(){
$('.search-box input[type="text"]').on("keyup input", function(){
/* Get input value on change */
var inputVal = $(this).val();
var resultDropdown = $(this).siblings(".result");
if(inputVal.length){
$.get("backend-search.php", {term: inputVal}).done(function(data){
// Display the returned data in browser
resultDropdown.html(data);
});
} else{
resultDropdown.empty();
}
});
// Set search input value on click of result item
$(document).on("click", ".result Button", function(){
$(this).parents(".search-box").find('input[type="text"]').val($(this).text());
// $(this).parent(".result").empty();
});
});
</script>
Are the results of the operator clicks to be placed into a single line (input) element or a multi-line (textarea) element?操作员点击的结果是放入单行(输入)元素还是多行(文本区域)元素?
First guess based upon code given would be var resultDropdown += $(this).siblings(".result");基于给定代码的第一个猜测是 var resultDropdown += $(this).siblings(".result");
BTW, welcome to the forums.顺便说一句,欢迎来到论坛。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.