Last active
December 17, 2015 05:57
-
-
Save marineko/4ae5588ef213f388517e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
var count; | |
var itemId; | |
$(document).ready( function () { | |
var numStr; | |
$().SPServices({ | |
operation: "GetListItems", | |
async: false, | |
listName: "counter", | |
completefunc: function (xData, Status) { | |
$(xData.responseXML).SPFilterNode("z:row").each( function () { | |
itemId= $(this).attr("ows_ID"); | |
count = Number($(this).attr("ows_Title")); | |
}); | |
} | |
}); | |
count++; | |
numStr = "CustomID - " + ("0000000" + count).slice(-8); | |
$("input[title='CustomID']").val(numStr).attr("readonly", "readonly").css("color", "#6a6a6a"); | |
$(":text:not([readonly])").eq(0).focus(); | |
}); | |
function PreSaveAction(){ | |
$().SPServices({ | |
operation: "UpdateListItems", | |
async: false, | |
batchCmd: "Update", | |
listName: "counter", | |
valuepairs: [["Title", count]], | |
ID: itemId, | |
completefunc: function(xData, Status) { | |
} | |
}); | |
return true; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment