[英]how to select select2 using another select2 values
I have two select2 input boxes, My requirement is if I selected one select2 box that value will effect with another select2 box. 我有两个select2输入框,我的要求是,如果我选择一个select2框,则该值将与另一个select2框一起生效。
my code is as below: 我的代码如下:
<input class="select2-offscreen itemid_0" type="text" name="itemid" id="itemid[]" style="width:100px; left:297.5px !important; top:863px !important; float:left !important" tabindex="-1" onchange="display();">
<input class="select2-offscreen unitId_0" type="text" name="unitId" id="unitId[]" style="width:100px; left:297.5px !important; top:863px !important; float:left !important" tabindex="-1">
<script>
function display(){
$(".unitId_0").select2("val","hr");
}
</script>
please tell me where I did mistake? 请告诉我我在哪里做错了?
Thanks, Madhuri 谢谢,Madhuri
这是您要找的吗?
$('.unitId_0').val("hr");
you can do this like,it should work. 你可以这样做,它应该可以工作。
var a=$(".itemid_0").val();
$('.unitId_0').val(a);
you can use keyup
or onclick
events 您可以使用
keyup
或onclick
事件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.