Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:19 AM
Hi,
i have a requirement to poplate a table of data of assets assigned with yes/no box.
i have written a widget script to populate, however the both the yes and no are getting clicked simultaneously, i only want either yes or no to be selected,
HTML:
<input type="checkbox" name="yes" id="yes" value="Ja" ng-click="c.setAction(item)">
<input type="checkbox" name="no" id="no" value="Nej" ng-click="c.setnoAction(item)">
client:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:27 AM
you should use radio buttons instead of checkboxes
HTML:
<input type="radio" name="yes_no" id="yes" value="Ja" ng-click="c.setAction(item)">
<label for="yes">Yes</label>
<input type="radio" name="yes_no" id="no" value="Nej" ng-click="c.setnoAction(item)">
<label for="no">No</label>
Client Script:
c.setAction = function(item) {
item.yes_no = 'Yes';
$('#' + item.asset).slideUp(400);
g_form.setValue('personlige_assets', JSON.stringify(c.data.assets));
};
c.setnoAction = function(item) {
item.yes_no = 'No';
item.notes = '';
$('#' + item.asset).slideDown(400);
g_form.setValue('personlige_assets', JSON.stringify(c.data.assets));
};
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:34 AM
hi Ankur
It didnt work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:38 AM
have already tried radio, however only one yes and no im able to select in total
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:50 AM
Thing is the code is only working on first row rest all its not working