locked
Hiding whole sections using JScript onload. RRS feed

  • Question

  •  

    Hi there,

     

    Just wondering if anybody has come across a JScript to use onload to hide whole sections within a form;

     

    In CRM 3 I used a the following code;

    Code Snippet

    crmForm.all.new_bbtidworkrequired.parentElement.parentElement.parentElement.style.display = 'none';

     

     

    If I used the first field within a section of the form it used to hide all the fields within.  Once we upgraded to CRM 4 this stopped working possibily due to changes in the backend.  I however haven't been able to find a script that hides the hole section.

     

    I am using this script in a form that has 30+ variables for different questions depending on a customer phone service requirements.  This also meant that is a certain question was asked and needed an answer I could onChange re-enable a manditory field that had to be answered.

     

    I have found 1 script that hides each individual attribute but was hoping to not have to rewrite the whole script and included all of the fields as there is almost 100 of them.

     

    Thanks for your help.

     

    Matthew

    Monday, July 28, 2008 12:59 AM

Answers

  • Your code still works with 4.0.  For example, I tested the following on the Account form to hide the Address section, and it worked:

    Code Snippet

     

    crmForm.all.address1_name.parentElement.parentElement.parentElement.style.display = 'none';

     

     

    Make sure that your schema name is correct, also, if you have any other code in the javascript event, if it is not working correctly, it could be conflicting or causing this code not to work.

     

    Monday, July 28, 2008 2:33 AM
    Moderator

All replies

  • Your code still works with 4.0.  For example, I tested the following on the Account form to hide the Address section, and it worked:

    Code Snippet

     

    crmForm.all.address1_name.parentElement.parentElement.parentElement.style.display = 'none';

     

     

    Make sure that your schema name is correct, also, if you have any other code in the javascript event, if it is not working correctly, it could be conflicting or causing this code not to work.

     

    Monday, July 28, 2008 2:33 AM
    Moderator
  •  

    Thanks Joel it did work.  I have removed everything but the hide and got it to work, so I will just need to review the other coding before this and find where i have gone wrong.

     

    Thanks,

    Monday, July 28, 2008 4:31 AM