Detect checkbox clicked

brycefraser
Giga Contributor

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!

1 ACCEPTED SOLUTION

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


View solution in original post

23 REPLIES 23

Hi Bryce, when you say filter down are you referring that none of the checked check boxes are getting copied over as checked to the RITM?



Thanks,


Berny


Sorry Berny, yes that is what I mean.



The boxes that were checked do not appear checked in the ritm after clicking order now


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


Hi Berny,



I've added that line on line 12 and it has stopped the entire client script to stop working.



I've tried moving it around to other sections in the code and still can't seem to get it working.



Any ideas?



Sorry for all the questions!



EDIT: Actually I have worked it out! Ended up changing the item.sys_id code to the item_sysid function.




Unfortunately it still doesn't carry across to the RITM after hitting submit.



If I disable the client script handling all this, it does go through properly.


Hi Bryce, here goes the code that I'm using. It works ok in a Fuji instance. I can see the checkbox selected in the RITM



function onLoad() {


 


          gel('ni.IO:dba29ae84fc20200fbb73fb28110c721').onclick = function() {


                              gel('IO:dba29ae84fc20200fbb73fb28110c721').value = this.checked;


                              if (typeof(variableOnChange) == 'function') variableOnChange('IO:dba29ae84fc20200fbb73fb28110c721');


                              alert('This is checked: ' + this.checked + ' and its value is ' + this.value);


                };


 


}