search

Home  >  Q&A  >  body text

javascript - How to assign value to multiple in js into the form of multi-select box below?


#If you want to realize the value in multiple, it will change with the changes of province, city and district.

I tried many ways to assign values ​​to multiple using js, but the value of multiple did not change.
Who knows how to solve it?

Multiple selections can be made in the multiple check box:
Picture description

Assignment code:

<select id="PositionList" multiple="multiple">
                        <c:forEach items="${sessionScope.positionl}" var="positionl">                             
                                    <option value="${positionl.name}">${positionl.name}</option>
                        </c:forEach>  
                         </select> 
              

<script type="text/javascript">

                            $(document).ready(function() {
                                $('#PositionList').multiselect();
                            });
                 </script>   
                 
                 

If js assigns a value to a general select:



success : function(data) {
                var jsonpos = data;
                var pos = "";
                for (var int = 0; int < jsonpos.length; int++) {
                    pos += "<option value="+jsonpos[int].name+">"
                            + jsonpos[int].name + "</option>";
                }
            }    

 这个就行了。但是 multiple 不能这样赋值,还请大神指教?
天蓬老师天蓬老师2801 days ago781

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:38:21

        document.getElementById('xxx').setAttribute('size',num) or $('xxx').attr('size',num)

    reply
    0
  • Cancelreply