duanjian9148
2017-05-18 07:45
浏览 133
已采纳

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

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>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题