Spaces/Official ESi/Scriptaculous & Adv. Tags

Hidden Automatic Datalink

Andrew Donnan
posted this on November 25, 2008 15:01

Automatically check and hide your datalink(s). If you only have ONE datalink setup on the input view, use the below script:

<script type="text/javascript">
document.forms[0].datalinkid.checked=true;
document.forms[0].datalinkid.style.display='none';
</script>

Tip:

  • If you have MORE THAN ONE datalink associated with the input view you must specify the id of the datalink in the script.
  • Datalink id's begin at zero.
    ex:
    <script type="text/javascript">
    document.forms[0].datalinkid[0].checked=true;
    document.forms[0].datalinkid[1].checked=true;
    document.forms[0].datalinkid[0].style.display='none';
    document.forms[0].datalinkid[1].style.display='none';
    </script>
 

Comments

User photo
Larry V Stephens
Indiana University

Every solution to this has some shortcomings so you have to decide which works best for you. For the original solution you must know what order your datalinks appear on the page. For the following you have to open the page to view the source code then do a search on that page to find the actual datalink and find its ID. This is assigned when the datalink is created and, as far as I can tell, is permanent. You can then use the following code to set the datalinks. You can either call it automatically in a startup script or on demand. You can also modify this code to make it a blackbox by cutting out the second "if" statement and substituting a variable (that you would pass in a calling routine) for the hard coded number.

<script type="text/javascript">

var LT = String.fromCharCode(60);

function checkRunningAccountDataLinks()

{

  var checkBoxes = document.forms[0].getElementsByTagName('input');

  for (var i = 0; eval(i + LT + checkBoxes.length); i++)  {

    <!--//this is the main running dialogue datalink -->
    if (checkBoxes[i].getAttribute('name') == 'datalinkid' &amp;&amp; checkBoxes[i].getAttribute('type') == 'checkbox' &amp;&amp; checkBoxes[i].getAttribute('value') == '144') {

      checkBoxes[i].checked = true;
      }
      
     if (checkBoxes[i].getAttribute('name') == 'datalinkid' &amp;&amp; checkBoxes[i].getAttribute('type') == 'checkbox' &amp;&amp; checkBoxes[i].getAttribute('value') == '145') {

      checkBoxes[i].checked = true;
      }
    
  }

}
</script>

 

September 10, 2009 08:44