David Tunnell David Tunnell - 4 years ago 99
HTML Question

Populating dropdown field with text when a row is selected

I have HTML where I am trying to populate a drop-down with string data using jQuery when an item is selected from a drop-down.

<td class="col-md-3" colspan="4">
<label class="control-label">{{item.fields[11].displayName}}22</label>
<div class="dropdown" style="width:100%">
<input type="text" class="form-control dropdown-toggle" data-toggle="dropdown" data-ng-disabled="formReadOnly" data-ng-model="item[item.fields[11].name]" data-ng-keyup="comboBoxGenOptions(2, 148, item[item.fields[11].name], 'searchGenericOptions')" />
<ul class="dropdown-menu" style="width:100%">
<li class="GpiId" data-ng-repeat="name in searchGenericOptions" style="width:100%"><a data-ng-click="changeData(item.fields[11].name, name)">{{name}}</a></li>
</ul>
</div>
<label class="error" data-ng-show="issueSuppNum()">Please insert a valid generic name.</label>
@*<div class="GenId" data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[7].htmlName)" data-strat-model="item" data-field="item.fields[7]"></div>*@
</td>


The drop down populates with an object:

enter image description here

When I click it, I want to show the GPI field:

$scope.changeData = function (propertyName, name) {
$scope.item[propertyName] = name;
$('GpiId').text(name.GPI);
};


The objects are being pulled on correctly:

enter image description here

What am I doing wrong and how do I fix it?

Edit: added class to field.

Answer Source

First, I think you missed a "." in your class selector.
$('GpiId').text(name.GPI);

to

$('.GpiId').text(name.GPI);

Second, since you are already using angular, I would try to use {{}} within GpiId instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download