A client wanted a signup form for some internal workshops/courses on their intranet. These were the requirements:
And you're done. Now what this script does, it simply retrieves the number of responses. When the ammount of responses exceeds 40 then it hides the 'make new elemets' and it adds a message. Now this solution isn't a 100% secure. When you know the exact 'add new item' URL you can still add an item. But in most scenario's this shouldn't be a problem.
- users should only be allowed to sign up once per course
- other users may not view or alter the items
- when the course is full (after say 40 sign-ups) the sign-up form should be closed
- Make a survey and add a few questions (address, why do you want to attend, etc.)
- go to the 'start' page of the survey. this should be called overview.aspx and should look like the image below
- Make sure that jQuery is loaded on the page and add a script editor webpart.
- Paste the code below in the script editor webpart and save your page.
<script>$(document).ready(function() {var count = $(".ms-summarystandardbody tr:nth-child(4) .ms-formbody").text(); // retrieve the number of responsesif (count > 40) { // when amount of survey entries is over 40$(".ms-menutoolbar > tbody > tr td:first").hide(); // hide 'add item' button$(".c1").show(); // show the 'this course is full' text}});</script><style>/* some css to hide the view selector */.ms-viewselector, .ms-listheaderlabel {display:none}</style><h2 class="c1" style="display:none">This course is full</h2>
And you're done. Now what this script does, it simply retrieves the number of responses. When the ammount of responses exceeds 40 then it hides the 'make new elemets' and it adds a message. Now this solution isn't a 100% secure. When you know the exact 'add new item' URL you can still add an item. But in most scenario's this shouldn't be a problem.