简体   繁体   English

jQuery设置一个的多个值 <select>不使用倍数=是

[英]jQuery set multiple values of a <select> without using multiple=yes

i'm lookin for an method, to set the more than one value of an without using the multiple funktion. 我正在寻找一种方法,可以设置一个以上的值而无需使用多重功能。

$("#multiselect .auswahl .options input").change(function(){
if($(this).is(":checked")){
    $("option[value='"+$(this).val()+"']",ele).attr("selected",true);
}else{
    $("option[value='"+$(this).val()+"']",ele).attr("selected",false);
}
});

This is HTML 这是HTML

<select name="kategorie[]" class="select">
   <option value="0" selected="">Bitte auswählen</option>
   <option value="2">A</option>
   <option value="3">B</option>
</select>

The Problem is, after sending the Form, the PHP gives only 1 value. 问题是,发送表格后,PHP仅提供1值。 Is there a possibility to get more than 1 selected option without using multiple? 是否有可能在不使用多个的情况下获得多个选择的选项?

Or is there a Way to Style the multiple like an not multiple? 还是有一种样式可以像不使用倍数一样?

Thanks for your help. 谢谢你的帮助。

Best Regards 最好的祝福

Chris 克里斯

You may add hidden field for every selected element on selection changing or change which data posts on .submit event for form or create select input with display:none and multiple="true". 您可以为选择更改中的每个选定元素添加隐藏字段,也可以为表单的.submit事件更改哪些数据过帐,或使用display:none和multiple =“ true”创建选择输入。 There is a lot of original ways to do this. 有很多原始方法可以做到这一点。

This jquery ui based widget provides a way to present multiselect with a similar look as the normal select. 这个基于jQuery ui的窗口小部件提供了一种以与普通选择类似的外观呈现多重选择的方法。

http://www.erichynds.com/blog/jquery-ui-multiselect-widget http://www.erichynds.com/blog/jquery-ui-multiselect-widget

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM