Home  >  Article  >  Backend Development  >  javascript - 下拉列表选择后无法变成已选择项

javascript - 下拉列表选择后无法变成已选择项

WBOY
WBOYOriginal
2016-06-06 20:18:021599browse

1.下拉列表选择后没有地址栏有相应的参数,数据也能查询出来但是下拉列表未能变成已选择项

html :

<code>            <div class="control-group">
                <label class="control-label span4">品牌:</label>
                <select class="m-wrap span8" id="disbrand">
                <option value="">请选择品牌</option>
                <?php foreach($brands as $v){?>
                <option value="<?php echo $v['brand_id']?>" echo isset :>>  <?php echo $v['brand_name']?>
</option>
                <?php }?>
                </select>
            </div>
        </code>

js :function dissearch(){

<code>var url = "/console/distribute/distribute/index/";
var agt = "?";
if($("#disbrand").val()!=""){
    url+=agt+"brand_id="+$("#disbrand").val();
    agt = "&";
}
</code>
  1. 贴上报错信息

  2. 贴上相关截图javascript - 下拉列表选择后无法变成已选择项

  3. 已经尝试过哪些方法仍然没解决(附上相关链接)

回复内容:

1.下拉列表选择后没有地址栏有相应的参数,数据也能查询出来但是下拉列表未能变成已选择项

html :

<code>            <div class="control-group">
                <label class="control-label span4">品牌:</label>
                <select class="m-wrap span8" id="disbrand">
                <option value="">请选择品牌</option>
                <?php foreach($brands as $v){?>
                <option value="<?php echo $v['brand_id']?>" echo isset :>>  <?php echo $v['brand_name']?>
</option>
                <?php }?>
                </select>
            </div>
        </code>

js :function dissearch(){

<code>var url = "/console/distribute/distribute/index/";
var agt = "?";
if($("#disbrand").val()!=""){
    url+=agt+"brand_id="+$("#disbrand").val();
    agt = "&";
}
</code>
  1. 贴上报错信息

  2. 贴上相关截图javascript - 下拉列表选择后无法变成已选择项

  3. 已经尝试过哪些方法仍然没解决(附上相关链接)

就是不知道你这个$args['brand_id']是否存在了,你先var_dump出来看看,实在不行的话,那个SELECTED改为selected="selected"

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn