Creating List/Document Library with Terms and Conditions sections

Often business comes with a requirement that they need to store data in the sharepoint list, however they need some information to be displayed on the New item page.
 
These kind of requirements although look very simple from business point of view, it becomes a nightmare if you want to create custom pages for it.
 
"Terms and conditions" option is one such requirement. Although you can implement it in various ways, here is a good option to create "T&C" text on new items page and enable the form only when these "T&C" are agreed. 
 
1. Create a List/Document library. http://spsite/Lists/ExampleList
2. Create the desired columns for the List/Document Library created
3. Open the http://spsite/Lists/ExampleList/Newform.aspx for that List/Document Library with the following query parameter “toolpaneview=2”. So your URL will look likehttp://spsite/Lists/ExampleList/Newform.aspx?toolpaneview=2
4. Now the newform.aspx page opens in edit mode.
5. Add a content editor webpart in the page. This content editor webpart should be added just above the fields of the form.
6. Add following HTML code in the webpart.

<div style="text-align: left">&#160;</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="text-align: left"><tbody><tr><td>
REPLACE THIS WITH YOUR TERMS AND CONDITIONS
<br/><br/> <font style="font-size: 12pt">
<input id="chkAgreement" onclick="apply()" type="checkbox" value="on"/>
<strong>I AGREE</strong></font><br/><br/><font style="font-size: 10pt
<br/></font></td></tr></tbody></table>
<script type="text/javascript">
function hideload()
{
var imag = document.getElementsByTagName('table');
for(var i=0;i<imag.length;i++)
{
if(imag[i].className.indexOf('ms-formtable') != -1 ) { var tbl = imag[i];}
if(imag[i].className.indexOf('ms-formtoolbar') != -1 ) { var tbl2 = imag[i];}
}
var ribbonhide = document.getElementById("s4-ribbonrow");
var stylechng = tbl.style;
var stylechng2 = tbl2.style;
var stylechng3 = ribbonhide.style;
stylechng.display = 'none';
stylechng2.display = 'none';
stylechng3.display = 'none';
}

function apply()
{
var imag = document.getElementsByTagName('table');
for(var i=0;i<imag.length;i++)
{
if(imag[i].className.indexOf('ms-formtable') != -1 ) { var tbl = imag[i];}
if(imag[i].className.indexOf('ms-formtoolbar') != -1 ) { var tbl2 = imag[i];}
}

var ribbonhide = document.getElementById("s4-ribbonrow");
var chkBx = document.getElementById("chkAgreement");
var stylechng = tbl.style;
var stylechng2 = tbl2.style;
var stylechng3 = ribbonhide.style;

if(chkBx.checked==false) {
stylechng.display = 'none';
stylechng2.display = 'none';
stylechng3.display = 'none';
}
else {
stylechng.display = 'block';
stylechng2.display = 'block';
stylechng3.display = 'none';
}
}
hideload();</script>
7. Add a content editor webpart in the page. This content editor webpart should be added just below the fields of the form.
8. Add following HTML code in the webpart.
<script>
hideload();</script>
Done.
If you don’t want to touch the ribbon control please remove the greyed out line above. Hiding the ribbon can be tricky as you might find it difficult to modify the webparts. But it gives a very good look and feel to the page if you remove it.
 
So if you have hidden the ribbon, you can edit the page by first closing content webpart, deployed in step 7 and 8. Then edit the page and redeploy the closed webpart.
 
 
 
 

No comments:

Post a Comment