Showing posts with label Disabled Field. Show all posts
Showing posts with label Disabled Field. Show all posts

Monday, February 11, 2013

Sharpeoint internal names display..

<select id="spLists" onchange="displayFieldData(this.options[this.selectedIndex].value)"/>
<div id="spListsSelected"></div>
<table id="spListFieldTable" cellpadding="0" cellspacing="0" style="width: auto"></table>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
var siteURL = 'http://' + window.location.host + L_Menu_BaseUrl + '/_vti_bin/lists.asmx';
$(document).ready(function(){
 var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
     <soap:Body> \
     <GetListCollection xmlns='http://schemas.microsoft.com/sharepoint/soap/' /> \
     </soap:Body> \
     </soap:Envelope>";
 $.ajax({
  url: siteURL,beforeSend: function(xhr) {
   xhr.setRequestHeader("SOAPAction",
   "http://schemas.microsoft.com/sharepoint/soap/GetListCollection");
  },
  type: "POST",
  async: false,
  dataType: "xml",
  data: soapEnv,
  complete: processResult,
  contentType: "text/xml; charset=\"utf-8\""
 });
});
function processResult(xData, status) {
 $("#spLists").append("<option>Select a List</option>");
 $(xData.responseXML).find("List").each(function() {
 var liHtml = "<option value='" + $(this).attr("Title") + "'>" + $(this).attr("Title") + "</option>";
 $("#spLists").append(liHtml);
 });
}
function displayValue(splistname) {
 $("#spListsSelected").text(splistname);
}
</script>
<script type="text/javascript">
var arrSkipFieldTypesOf = ['Computed'];
var arrIncludeOverrideFields = ['Title','Author','Created','Modified','Editor'];
function displayFieldData(listname) {
 if(listname == "" || listname == undefined) return false;
 var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
     <soap:Body> \
     <GetList xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
     <listName>" + listname + "</listName> \
     </GetList> \
     </soap:Body> \
     </soap:Envelope>";
 $.ajax({
  url: siteURL,
  beforeSend: function(xhr) {
  xhr.setRequestHeader("SOAPAction",
  "http://schemas.microsoft.com/sharepoint/soap/GetList");
  },
  type: "POST",
  async: false,
  dataType: "xml",
  data: soapEnv,
  complete: processResult2,
  contentType: "text/xml; charset=\"utf-8\""
 });
}
function processResult2(xData, status) {
 $("#spListFieldTable tr").remove();
 $("#spListFieldTable").append("<tr style='font-weight:bold;'><td style='padding-right:10px'>DisplayName</td><td style='padding-right:10px'>FieldInternalName</td><td style='padding-right:10px'>FieldType</td></tr>");
 $(xData.responseXML).find("Field").each(function() {
  if (($.inArray($(this).attr('Name'),arrIncludeOverrideFields)>-1) || ($(this).attr('FromBaseType')!='TRUE' && $(this).attr('Sealed')!='TRUE' && $(this).attr('DisplayName')!=undefined && $.inArray($(this).attr('Type'),arrSkipFieldTypesOf)==-1)) {
   var trHtml = "<tr>";
   trHtml += "<td style='padding-right:10px'>" + $(this).attr("DisplayName") + "</td>";
   trHtml += "<td style='padding-right:10px'>" + $(this).attr("Name") + "</td>";
   trHtml += "<td style='padding-right:10px'>" + $(this).attr("Type") + "</td>";
   trHtml += "</tr>";
   $("#spListFieldTable").append(trHtml);
  }
 });
 $("#spListFieldTable tr:odd").css("background-color","rgb(206,206,206)");
}
</script>

Wednesday, July 25, 2012

Sharepoint form redirection


<script type="text/javascript" src="SITE/Images1/jquery-1.3.2.min.js%22%3E%3C/script>
<script type="text/javascript">
fields = init_fields();
// Where to go when cancel is clicked
goToWhenCanceled = 'http://sharepoint.apps.anz/teams/BHS/UnOccupied-Thanks.aspx';
// Edit the redirect on the cancel-button's
$('.ms-ButtonHeightWidth[id$="GoBack"]').each(function(){
    $(this).click(function(){
   STSNavigate(goToWhenCanceled);
   })
});
function init_fields(){
  var res = {};
  $("td.ms-formbody").each(function(){
   if($(this).html().indexOf('FieldInternalName="')<0) return;
   var start = $(this).html().indexOf('FieldInternalName="')+19;
   var stopp = $(this).html().indexOf('FieldType="')-7;
   var nm = $(this).html().substring(start,stopp);
   res[nm] = this.parentNode;
  });
  return res;
}
</script>


Disable edit on fields on a SharePoint form


<SCRIPT language=javascript>
function DisableField(title)
{
    for(var i = 0; i < document.all.length; i++)
    {
        var el = document.all[i];
        if(el.title == title)
        {
            el.readOnly = true;
            break;
        }
    }
}
DisableField("Bay");
DisableField("Pos");
DisableField("Status");
</SCRIPT>

Followers

No Locks without Key

🌿 Bible Verse 1 Corinthians 10:13 "No temptation has overtaken you except what is common to mankind. And God is faithful; ...

Who Am I?

My photo
What is mankind that you are mindful of them, human beings that you care for them? Psalms 8:4 But he made us a little lower than Angels and Crowned with Glory and Honor. How majestic is your name in all the Earth Oh Lord our God!