I am trying to fill in a text box based on the checked, numbered items list on a website.
So far, this is what I have. It works on
jsfiddle.net (Big IF) I don't use the actual identifier of the checkbox. For example, cbNo1-33.1 is the id of a checkbox.
Each checkbox identifier has a unique word dash number. so when I write the identifier into javascript and jQuery, I get an error. Is there a way around this issue?
//copy and paste into jsfiddle
//HTML
<label>Skill Overall</label>
<input type="text" size="40" id="txtComment" name="txtComment"/>
<br /><br />
<label>Skill Number and Name of the Skill</label>
<input type="checkbox" id="cbNo1" />
// Javascript + JQuery/jquery-3.4.1
$(document).ready(function(){
$("#cbNo1").on("click", function () {
var ibComment;
if ($(this).is(":checked")) {
ibComment = $('[name="ibComment"]').val();
$("#txtComment").val("CS Comment what they missed").prop("readonly", false);
} else {
$("#txtComment").val("").prop("readonly", false);
}
});
});