我想在onclick下拉列表的基础上获取值,并使用jquery在输入中显示

atmip9wb  于 2022-12-18  发布在  jQuery
关注(0)|答案(1)|浏览(117)
<div class="wrapper-dropdown" id="primary_destination">
                                            <span>Primary Destination</span>
                                            <ul class="dropdown"  >
                                                @foreach(DB::table('formcountries')->get() as $r)
                                              <li data-v-6e3bf6e8="{{ $r->code }}" data-title="{{ $r->name }}" value="{{ $r->name }}" class="optionselect" id="selectboxes" onclick="optionselect(this.value);"><span class="selectspan">{{ $r->name }}</span></li>
                                              @endforeach
                                            </ul>
                                          </div>
<script type="text/javascript">
    function optionselect(value) {
  var params = $('#selectboxes').val();
  $('#testfield2').val(params);
}
</script>

〈输入数据-v-5170 d561 ="”类型=“文本”占位符=“目的地”

arknldoa

arknldoa1#

On click of dropdown, the value will display in the input textbox.

Following is the code sample

<select name="ddlNumbers" id="ddlNumbers" onchange="getSelectedValue(this.value)">
  <option value="one">One</option>
  <option value="Two">Two</option>
  <option value="Three">Three</option>
  <option value="Four">Four</option>
</select>
<input id="txtvalue" type="text" placeholder="Destination"/>
    
function getSelectedValue(evt){
console.log(evt);
$('#txtvalue').val(evt);
}

相关问题