Here's some simple JQuery to help you avoid looking for those annoying GUID's
var list = [];
var peoplePicker1;
var peoplePicker2;
var currentObject;
$(document).ready(function() {
// use this ^ for wildcard hiding/showing all items that begin with "xxx"
$('[title^="xxx"]').closest('tr').hide();
$('[title^="xxx"]').closest('tr').show();
$('DIV[id^="sectionSection2"]').hide();
// will need this to hide date/time fields
$('nobr:contains("Hire Car")').closest('tr').hide();
// use for text fields and drop down lists
var x = $('[title$="Authoriser"]').val();
// use for radio and checkboxes
// where title$ is the choice option
$('[title$="Enter Choice #1"]').click(function() {
alert('Please ensure you complete the Tracking section');
// get the radio button id
var tmp = $(this).children('input').attr('id');
// check its value
alert($("input[id="+tmp+"]:checked").val());
var checked = $("input[id="+tmp+"]:checked").val();
if(checked == 'on')
{
// do something
}
});
// use for people pickers
// add each people picker to an array and assign it to a var
// start loop
$(".ms-inputuserfield").each(function(){
list.push($(this).text());
currentObject = $(this);
});
// end loop
peoplePicker1 = list[0];
peoplePicker2 = list[1];
currentObject.attr('disabled','disabled');
var currentUser = $().SPServices.SPGetCurrentUser({
fieldName: "Title",
debug: false
});
// check if the user is an admin user
function isAdmin(user)
{
var adminUser1 = "System Account";
var adminUser2 = "john smith";
var adminUser3 = "john doe";
var adminUser4 = "dave nixon";
var adminUser5 = "fred smith";
if(user == adminUser1 || user == adminUser2 || user == adminUser3 || user == adminUser4 || user == adminUser5)
{
return "admin";
}
else
{
return "not admin";
}
}
function CheckForAttachment()
{
var elm = document.getElementById("idAttachmentsTable");
if(elm == null || elm.rows.length == 0)
{
alert("No e-training form attached");
return false;
}
else { return true; }
}
function PreSaveAction()
{
return CheckForAttachment();
}
});
No comments:
Post a Comment