1

I have a list on my Sharepoint site called "Teams"

It has an external list called "Country"

How can I call "Country" to hide?

I have my JS on the new form working and I tried

document.getElementById("Country").style.display='none';
0

You can do it this way. It works very well for form controls:

SP 2010 version:

function findcontrol(field) {
    var arr = document.getElementsByTagName("!");
    // get all comments
    for (var i=0;i < arr.length; i++ )
    {
        // now match the field name
        if (arr[i].innerHTML.indexOf(field) > 0)
        { 
            return arr[i]; 
        }
    }
}

_spBodyOnLoadFunctionNames.push("hideFields");

function hideFields() 
{
    var control = findcontrol("ControlToHideTitle");
    control.parentNode.parentNode.parentNode.style.display="none";
}

SP 2013 Version:

_spBodyOnLoadFunctionNames.push("hideFields");

function findcontrol(field) {
    var arr = document.getElementById(field);
    return arr;
}

function hideFields() 
{
    var control = findcontrol("ControlToHideTitle");
    control.parentNode.parentNode.parentNode.style.display="none";
}

This will hide everything on the NewItem.aspx for that control. Give this a try.

  • Thank you very much! I use SP 2013 version and works? Now i want that appears depend the selection of another field. What can I do? CAML query? – Paolo Frigenti Apr 24 '18 at 8:11
0

try

window.onload = function() {
     document.getElementById("Country").style.display = 'none';
};

Sometimes in sharepoint you'll find that YOUR javascript will run before THEIR page is fully loaded. So this is a workaround.

  • Works too! Thanks :) Now i want that appears depend the selection of another field. What can I do? CAML query? – Paolo Frigenti Apr 24 '18 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.