Jump to content
  • 0

Make Checkbox True If Textfield Content Changes To A Specific Value



Hi, I have a submission datapage which contains dropdown. The dropdown has 4 items in the list. If the item selected = "PAT" I want the checkbox (PAT_Test) to be automatically checked and disabled. The code I'm using doesn't check the checkbox. I'd be very grateful if someone could show me if there's an error and how to correct it.

Here's the code I'm using:-

document.addEventListener('DataPageReady', function() {
document.getElementById("InsertRecordSurvey_Group_Type").addEventListener('change', function() {
if(document.querySelector("[id*='InsertRecordSurvey_Group_Type']").value == "PAT");
  document.querySelector("[id*='InsertRecordPAT_Test']").value = 1;
  document.querySelector("[id*='InsertRecordPAT_Test']").disabled = true;

}); // end of change event listener
}); // end of DataPageReady event listener

Thanks in anticipation

PAT Selected.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Hi @RonAnderson - can you try this instead? 

<script type="text/javascript">

document.addEventListener('DataPageReady', function (event) {
    document.querySelector("[id*='InsertRecordFirst_Name']").addEventListener('change', function() {
        if (document.querySelector("[id*='InsertRecordFirst_Name']").value == 'PAT') {
         document.querySelector("[name*='InsertRecordYesNo']").checked = true;
      } else {
         document.querySelector("[name*='InsertRecordYesNo']").checked = false;


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...