- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2015 04:26 PM
Hey all
I have a catalogue form with a large list of checkboxes.
I'd like to know how to detect which checkbox has been clicked by a requestor so I can apply a style to differentiate it from the checkboxes that are auto-filled.
I've no idea where to start.
Anyone got any ideas?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2015 11:36 PM
Hi Bryce, you were right! Here goes the fix. Add the following at the beginning of your inline defined onclick function (@ line 12)
gel('IO:' + item.sys_id).value = this.checked;if (typeof(variableOnChange) == 'function') variableOnChange('IO:' + item.sys_id);
I'll appreciate if you can mark this post as the correct one or as a helpful one so that others reading this post in the future know that this line is *key* to be added in the inline defined onclick function.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 03:41 PM
Sorry for hassling you so much Berny.
I still can't seem to get it to work.
Here is the script I am currently running:
function onLoad() {
//Type appropriate comment here, and begin script below
var target = new GlideRecord('item_option_new');
target.addQuery('variable_set', '2d18189c288e4200582e4db8471a13ab');
target.query();
while (target.next()){
if (target.type == '7'){
var item_sysid = target.sys_id;
gel('ni.IO:' + item_sysid).onclick = function() {
gel('IO:' + item_sysid).value = this.checked;
if (typeof(variableOnChange) == 'function') variableOnChange('IO:' + item_sysid);
// get sys id from io object
var nam = this.name.split(":");
var nam = nam[1];
// get name from sys id
var fieldtarget = new GlideRecord('item_option_new');
fieldtarget.addQuery('sys_id',nam);
fieldtarget.query();
while (fieldtarget.next()){
var targetname = fieldtarget.name;
}
if (this.checked == true){
g_form.getControl(targetname).parentNode.style.color = 'red';
g_form.getControl(targetname).parentNode.style.fontWeight = 'bold';
} else{
g_form.getControl(targetname).parentNode.style.color = 'black';
g_form.getControl(targetname).parentNode.style.fontWeight = 'normal';
};
};
};
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 03:59 PM
Hi Bryce, no worries! We're here to help.
Here goes a couple of recommendations:
a) In line 6, you may want to add a target.addQuery('cat_item', sys_id_of_your_catalog_item);
b) Your could add another addQuery so that it will only retrieve the checkboxes. Something like target.addQuery('type', '7');
c) I'll probably comment out lines 16 through 38 and make sure that the rest of the code is working as expected.
d) lines 38, 42 and 43 do not need a ; -- all of these should only have a } -- without a ;
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 03:59 PM
I hope this is helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 04:16 PM
Thanks Berny,
Going through these steps now. I'll let you know once I sort it out.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 04:51 PM
Great. Looking forward to hear if it worked