Skip to main content

Does anyone know how you get the value of a checkbox with javascript?  I have a checkbox with one value called override and the field value is stored in the variable varGROR

I tried these and others but none work:

 

 

 

 

NWF$('#' + varGROR).val();

 

NWF$('#' + varGROR + ' option:selected');

 

Can anyone help?

To get value of checkbox try

 

NWF$('#' + varGROR).prop('checked')

 

It will return 'true' or 'false'.


Thanks.  That works if I change my field from a choice field  checkbox with 1 option to a yes no checkbox with one option.

I don't suppose you also know how to get the value of a choice field with option or check boxes where there are multiple options, as I keep getting 'undefined'


Hi Liz,

A multichoice control will store the entries as an Array. The following code can execute on  a mult Choice control with a JavaScript Variable named 'multiChoices'. The log entry occurs on a button click calling the showMe() function.

  1. function showMe() {
  2.   var c = "];
  3.   NWF$('#' + multiChoices + ' :checkbox:checked').each(function(i) {
  4.    c0i] = NWF$(this).val();
  5.    console.log(c9i]);
  6.   });
  7. }

Thank you,

Sean Fiene


Thanks Sean. I'll give that a go


Hey @sean_fiene,



How did you store this to a variable so that I can call it from a different list?


Reply