如何使用jQuery获取选定的下拉列表值

时间:2016-04-02 11:10:22

标签: php jquery ajax

我想在下拉菜单中获取所选值以进行编辑。但是我选择了下拉列表中的所有值。

    function getinstruments() {

         var model=$('#model').val();
         var brand=$('#brand').val();

         brand = brand.split('%') ;
         model = model.split('%') ;



        $.getJSON("{!! URL::route('appraisal.getinstrument') !!}", {brand: brand[0],model:model[0]}, function(data) {


             if(data.success)
                {
                $('select[name="sub_model"]').find(":selected").html(data.sub_models_array);
                $('select[name="color"]').find(":selected").html(data.colors_array);
                $('select[name="top"]').find(":selected").html(data.top_array);
                $('select[name="neck"]').find(":selected").html(data.neck_array);

                }
            });
        }   

不知道此代码的问题是什么。对此问题的答复表示赞赏

<div class="col-lg-6 col-xsm-6">    
        <h4>Enter Body wood details</h4>
             <div class="form-group">
                <label>Top Wood</label>
                <select name='top_wood' class='form-control'  placeholder ='Enter Top wood' id='top'>
                <option value=''>Pick a topWood</option>

                </select>


             </div>

              <div class="form-group">
                <label>Back Woord</label>
                <select name='back_wood' class='form-control'  placeholder ='Enter Back wood' id='back'>
                <option value=''>Pick a topWood</option>

                </select>

            </div>

              <div class="form-group">
                <label>Neck Wood</label>
                <select name='neck_wood' class='form-control'  placeholder ='Enter Neck wood' id='neck'>
                <option value=''>Pick a NeckWood</option>                   
                </select>

            </div>



        <div class="form-group">
                <label>Select color</label>
    <select name='color' class='form-control' id='color' >
                <option value=''>Pick a color</option>

                </select>

            </div>

            <div class="form-group">
                <label>Frets</label>
                <select name='frets' class='form-control'  placeholder ='Enter Frets' id='frets'>
                <option value=''>Pick a Fingerboard Material</option>                   
                </select>

            </div>
            <div class="form-group">
                <label>Turner</label>
                <select name='turner' class='form-control'  placeholder ='Enter Turner' id='turner'>
                <option value=''>Pick a Fingerboard Material</option>                   
                </select>

            </div>

这是我的视图文件,我想要选择dropdaown值

0 个答案:

没有答案