Reputation: 683
I have a survey list. I need to hide a particular question by placing javascript in a content editor webpart. Can anybody give me the proper javascript code to hide the question in the survey list?
Upvotes: 0
Views: 4065
Reputation: 1231
The People Picker is a little trickier to pin down due to the way it is rendered in the browser, try something like this
var searchText = RegExp("FieldName=\"[YOUR PEOPLE PICKER NAME]\"", "gi");
$("td.ms-formbody").each(function() {
if(searchText.test($(this).html()))
{
$(this).find("div[Title='People Picker']").css('display', 'none');
return false;
}
});
Upvotes: 0
Reputation: 1231
document.getElementById('MyQuestionID').style.display = 'none';
Though I'd suggest using JQuery and traversing up the dom from the element you want to hide, to hide the thjat the element is contained within. In which case, load the JQuery JS file and use something like:
$(document).ready(function() {
$('input[title="MyQuestionTitle"]').parent().parent().css("display","none");
});
Upvotes: 1