I'm trying to prevent users from editing an item after i've set a "WIP cutoff". I have a checkbox to set this and I'm trying to get the status of that checkbox using a function that has been used extensively in an existing customised sharepoint 2007 site. The Function is:
function getField(fieldType,fieldTitle) {
var docTags = document.getElementsByTagName(fieldType);
for (var i=0; i < docTags.length; i++) {
if (docTags[i].title == fieldTitle) {
return docTags[i]
}
}
}
So in order to get the "Checked Status" of the box:
<input name="ctl00$m$g_0c239981_ad37_4fda_8a14_7015542b4518$ff113_1$ctl00$ctl00$BooleanField" title="WIP Closed Off" id="ctl00_m_g_0c239981_ad37_4fda_8a14_7015542b4518_ff113_1_ctl00_ctl00_BooleanField" type="checkbox" CHECKED="checked" value="on"/>
I'm using with the help of share points built-in "PreSaveAction" function [so I've been told]:
// PreSaves Edit WIP NEW
function PreSaveAction() {
if (getField('input', 'WIP Closed Off').CHECKED == "checked") {
alert("This Campaign has been closed, you can not edit products.");
//return false;
history.go(-1);
}
}
I originally thought that I should be getting the "Value" of the checkbox but it is alway ON regardless of the checkbox state.
Any help appreciated.