Hi to everyone.
I have an html table with some submitted values from a previous task form and I want to (display/hide) an extra input field each time I click (select/unselect) on the respective checkbox of each table row.
My problem here is that the desired extra input field can not be displayed by clicking on the body section (my first 2 rows) of my table. In addition, by clicking (select/unselect) on the foot section of my table (my last row), I display/hide all the extra input fields (the last and the 2 previous ones).
I have found something relative here: AngularJS CheckBox: Show Hide (Toggle) HTML DIV on CheckBox click using ng-show and ng-change
I also uploaded my code (with some comments) and 2 screenshots in case anyone can help me:
Thank you
<form role="form">
<script cam-script type="text/form-script">
camForm.on('form-loaded', function() { // The variable 'item' has not been loaded (fetched) from the server yet.
camForm.variableManager.fetchVariable('item'); // We tell the "Form SDK" to fetch the 'json' variable named 'item'.
});
camForm.on('variables-fetched', function() { // The variable 'item' has been loaded (fetched) from the server
$scope.item = camForm.variableManager.variableValue('item'); // and is bound to the current AngularJS $scope of the form.
});
$scope.IsVisible = false; // The value of the variable "IsVisible" is initially set to "false" and hence the HTML DIV is hidden when page loads.
$scope.ShowHide = function () { // We make a function named "ShowHide".
$scope.IsVisible = $scope.ShowQuantity; // Inside the "ShowHide" function the value of the variable "IsVisible" is reversed.
}
</script>
<h2>My List of Choices</h2>
<div>
<table>
<tr>
<th>Category</th>
<th>Brief Description</th>
<th>Detailed Description</th>
<th>Price</th>
<th></th>
<th></th>
</tr>
<tbody ng-repeat="x in item track by $index">
<tr>
<td><input type="text" value="{{x.Category}}" readonly="true" /></td>
<td><input type="text" value="{{x.BriefDescription}}" readonly="true" /></td>
<td><input type="file" value="{{x.DetailedDescription}}" readonly="true"
cam-variable-name="DetailedDescription"
cam-variable-type="File"
cam-max-filesize="10000000" /></td>
<td><input type="text" value="{{x.Price}}" readonly="true" /></td>
<td><input type="checkbox" ng-model="ShowQuantity" ng-change="ShowHide()"
cam-variable-name="is_item_selected"
cam-variable-type="Boolean" /></td>
<td ng-show="IsVisible">Quantity: <input type="number"
cam-variable-name="quantity" min="1"
cam-variable-type="Integer" /></td>
</tr>
</tbody>
<tfoot>
<tr>
<td><input type="text" ng-model="Category" readonly="true" /></td>
<td><input type="text" ng-model="BriefDescription" readonly="true" /></td>
<td><input type="file" ng-model="DetailedDescription" readonly="true"
cam-variable-name="DetailedDescription"
cam-variable-type="File"
cam-max-filesize="10000000" /></td>
<td><input type="text" ng-model="Price" readonly="true" /></td>
<td><input type="checkbox" ng-model="ShowQuantity" ng-change="ShowHide()"
cam-variable-name="is_item_selected"
cam-variable-type="Boolean" /></td>
<td ng-show="IsVisible">Quantity: <input type="number"
cam-variable-name="quantity" min="1"
cam-variable-type="Integer" /></td>
</tr>
</tfoot>
</table>
</div>
</form>