Home > WebEOC > Admin Guide > Board Building Tips > Click Datalinks when Check Boxes are Checked

Click Datalinks when Check Boxes are Checked

Table of contents

The JavaScript below is designed to check/click a datalink only if a specific check box is checked. This function must be called to be implemented. The easiest way to do so is by using the HTML <onclick> attribute in the <checkbox> tag.

<input type="checkbox" name="Name_of_Your_Checkbox_Field_1" onclick="checkDatalink()"/>

The above calls the function below and causes the datalink to be checked if the condition is met. If the condition is not met, the datalink is not checked.

<script type="text/javascript">
  function checkDatalink()
  {
    if(document.forms[0].Name_of_Your_Checkbox_Field_1.checked == true)
    { 
      document.forms[0].datalinkid.checked = true; 
    } 
    else
    {
      document.forms[0].datalinkid.checked = false;
    } 
  }
</script>

Tips

  • This code only works for input views where only one datalink exists. 

  • After this function is implemented correctly, you may wish to hide your datalink, depending on the design of your boards involved. To do this, use the <span> tags or the HTML <style> attribute of the <tr> or <td> tags. 

  • If more than one check box exists and you need the datalink to be checked if either of the check boxes are checked, you can use an OR boolean in the JavaScript if statement. The rest of the script will be the same.

if(document.forms[0].Name_of_Your_Checkbox_Field_1.checked == true || document.forms[0].Name_of_Your_Checkbox_Field_2.checked == true)
You must to post a comment.
Last modified

Tags

Classifications

This page has no classifications.