cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

get checkbox value with javascript

Jump to solution

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?

Labels: (1)
Tags (1)
Reply
5 Replies
Workflow Hero

Re: get checkbox value with javascript

Jump to solution

To get value of checkbox try

 

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

 

It will return 'true' or 'false'.

Reply
Workflow Hero

Re: get checkbox value with javascript

Jump to solution

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'

0 Kudos
Reply
Not applicable

Re: get checkbox value with javascript

Jump to solution

Hi, liz fowles​. If you get a solution in this threat, please select the "correct answer," it helps others in the community looking for correct answers. If not, your feedback is always welcome! Thank you!

0 Kudos
Reply
Workflow Hero

Re: get checkbox value with javascript

Jump to solution

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.    c[i] = NWF$(this).val();
  5.    console.log(c[i]);
  6.   });
  7. }

Thank you,

Sean Fiene

0 Kudos
Reply
Workflow Hero

Re: get checkbox value with javascript

Jump to solution

Thanks Sean. I'll give that a go

0 Kudos
Reply