- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 07:17 AM
When one select box value is selected, the other select box values in the table are changed. Is there anything wrong with the code?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 01:00 PM
I'm assuming you want to prevent submission functionality if the required fields are not filled?
You need to add a name attribute to the form
<form name="formName">
Then check if the form is valid (all required fields are met) when the submit button is clicked
<button class="test" class="btn btn-primary btn-block" ng-click="c.uiAction('remove')" ng-disabled="formName.$invalid">Keep All</button>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 08:02 AM
Hi Revathi,
It sounds like you are describing a table with multiple select inputs, but I just see one in your code. Are all the inputs mapped to the same ng-model, c.data.manager_action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 08:57 AM
Yes @TFischer . I need help understanding how to add a different ng-model each time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 09:17 AM
Sure, I can't be certain without seeing your full html and client script but I'm assuming that the other select inputs are bound to the same ng-model, which is telling your inputs that all they should all share the same value.
If your inputs require unique values, they need unique ng-model variables. If you are rendering rows in a table with ng-repeat, that's not going to work.
I would need to see the html template and client script to help you find a more specific solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2024 09:21 AM
HTML Script:
<form>
<div>
<button class="test" class="btn btn-primary btn-block" ng-click="c.uiAction('remove')">Keep All</button>
<br/>
<table border="1px solid black">
<tr>
<th>Employee Number</th>
<th>Employee Name</th>
<th>Department</th>
<th>Division</th>
<th>End Date</th>
<th>Action</th>
</tr>
<tr ng-repeat="x in data.arr">
<td>{{x.employee_number}}</td>
<td>{{x.u_name}}</td>
<td>{{x.departmentname}}</td>
<td>{{x.division}}</td>
<td>{{x.enddate}}</td>
<td><select id="manager_action" ng-model="c.data.manager_action"
class="form-control" ng-change="c.changeAction({{x.employee_number}})"
ng-options="y.name for y in data.actions" ng-required="true">
</select>
</td>
</tr>
</table>
</div>
</form>
Client Script:
api.controller=function($scope,spModal) {
/* widget controller */
var c = this;
c.changeAction=function(number)
{
c.data.empnumber=number.toString();
c.data.action=c.data.manager_action.value.toString();
if(number!='')
{
if(c.data.manager_action.value=='2')
{
spModal.open({
title: 'Reason for deactivating CW',
buttons:[],
widget: 'cwdeactivation',
widgetInput: {sys_id:number,action:'Remove'}
}).then(function(response) {
});
}
else if(c.data.manager_action.value=='1')
{
c.server.update();
}
}
}
};