AnsweredAssumed Answered

Javascript to set a checkbox to true by button click

Question asked by cjones69 on Jul 10, 2018
Latest reply on Aug 21, 2018 by cjones69

I need to create a button that will set a hidden checkbox field to true and then submit the form. I'm not a coder, but dally with javascript occasionally. I've searched everywhere for pre-existing code to do the task I am attempting, but can't find anything. I saw some posts about UNchecking radio buttons using javascript and I tried to modify it to make it work with the checkbox, but no go. Below is the code I tried:

NWF$('document').ready(function(){var strBeginReviewValue = NWF$('#'varBeginReviewID).find("input:checkbox:not(:checked)").val();NWF$('#'varBeginReviewID).find('input[value='\'strBeginReviewValue'\']').attr('checked', true);});

varBeginReviewID is the javascript ID for my checkbox. I placed this code in the client click field of the button. It does not set the checkbox to checked. The code above also does not submit the form. If anyone can help me get the button to do both the checking of the checkbox and submitting the form, it would be greatly appreciated!


Thanks!

Chris

Outcomes