循环select和取赋值
Posted hpwd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了循环select和取赋值相关的知识,希望对你有一定的参考价值。
bootstrap:
<!--列表容器-->
<div class="panel-body" style="position:relative;">
<form id="searchForm">
</form>
</div>
1 var html = ""; 2 for (var m = 1; m < Math.ceil(dataList.length/3)+1; m++) { 3 html += ‘<div class="row form-inline form-group" >‘; 4 for (var n = 1; n < 4; n++) { 5 html += ‘<div class="col-lg-4 col-md-4 col-xs-4 col-sm-4">‘; 6 html += ‘<select class="form-control" style="width: 30%;text-align: center;background-color: #6495ED" onchange="changeSelect()">‘; 7 html += ‘ <option value="">---请选择---</option>‘; 8 for (var i = 0; i < dataList.length; i++) { 9 html += ‘ <option value="‘ +dataList[i].value+ ‘">‘ +dataList[i].name+ ‘</option>‘; 10 } 11 html += ‘</select>‘; 12 html += ‘<span type="text" class="form-control" aria-describedby="basic-addon1" style="width: 30%;text-align: left"></span>‘; 13 html += ‘</div>‘; 14 } 15 html += ‘</div>‘; 16 } 17 $("#searchForm").html(html);
for (var k = 0; k < document.getElementsByTagName("select").length; k++){ if ( document.getElementsByTagName("select")[k].value == price.symbol){ document.getElementsByTagName("span")[k].innerHTML = price.Price; } }
以上是关于循环select和取赋值的主要内容,如果未能解决你的问题,请参考以下文章