如何在文本框中显示下拉列表选定值

When I choose from the dropdown list, I want to get the selected value of the dropdown list and show in the . But I try to do with above code, it didn't work ? whats wrong on that, plz suggest me. Thanks

$('.assetgroupSelect').on('change', function () {
  var value = $('.assetgroupSelect').val();
  if (value != "") {            
    $('#idValue').text(value)
  }
}).trigger('change');
<?
  $select_query = "Select Group_ID, Group_Name from Asset_Group";
  global $DB;
  $arrResult = array();
  $err_mess = 'Test';
  $result = $DB->Query($select_query, false, $err_mess.__LINE__);
?>

<tr height="50">
  <td style="width: 220px">
    <label for="assetGroup">
      <span style="color:red">*</span>Asset Group:
    </label>
  </td>
  <td>
    <select id="assetgroupSelect" name ='assetgroupSelect'>
      <option value="">(choose asset group)</option>
      <? while ($arrResult = $result->Fetch()) { ?>
        <option value="<? echo $arrResult['Group_ID'] ?>"> <? echo $arrResult['Group_Name'] ?> </option>
      <? } ?>
    </select><br><br>
    <div class="placer"> 
      Current index is :
      <div id="idValue"></div>
    </div>
  </td>
</tr>
查看全部
duanjian9148
duanjian9148
2017/05/18 07:45
  • php
  • dropdown
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复