Friday, April 20, 2012

Hiding Fields in SharePoint Page's

Hiding fields in SharePoint Page's

(Newform.aspx / EditForm.aspx / Disp.aspx)

Open your website in the SharePoint Designer. Then open your Library. Go into the Form Section then Click on the page (Newform.aspx / EditForm.aspx / Disp.aspx). Click in advanced mode in Ribbon then only you were able to make the changes in the code. Then search for the Below Tag :
<asp:ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat = "server">
Now Copy the below code and paste it there.
You need to change the Field 1 and Field 2 values only .


<script type="text/ecmascript">

ExecuteOrDelayUntilScriptLoaded(runCode, "sp.js"); function runCode() {
HideField("Expose to Customer / Partner",true); HideField("Field 1",true);
HideField("Field 2",true); } // Function To Hide Fields
function HideField(title,hide){
var header_h3=document.getElementsByTagName("h3") ;
for(var i = 0; i <header_h3.length; i++)
{
var el = header_h3[i];
var foundField ;
if(el.className=="ms-standardheader")
{
for(var j=0; j<el.childNodes.length; j++)
{
var mHead=title+"<SPAN class=ms-formvalidation> *</SPAN>";
if(el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title || el.childNodes[j].innerHTML==mHead)
{
var elRow = el.parentNode.parentNode ;
if(hide==true)
{
elRow.style.display = "none"; //and hide the row
}
else
{
elRow.style.display = "visible"; //and show the row
}
foundField = true ;
break;
}
}
}
if(foundField)
break ;
}
}

</script>

 Wow...!! You're Done...!! Any Query....??

Thursday, April 5, 2012

Getting Dropdown selected Value and Selected Text using JQuery


                 Getting Dropdown selected Value and Selected Text using JQuery

Some we require to get the selected value(id) with their corresponding value. So we can get by this way :-
This is simplest way to get :-

<script type="text/javascript" src="jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function()
{
$("#btnGetDropDownValue").click(function()
{
alert('DropDown Value '+$("#ddlSample").val());
alert('DropDown Text '+$("#ddlSample").find('option').filter(':selected').text());
});
});
</script>
Call the subsequent parameter where you want to use :-

<table cellpadding="0" cellspacing="0">
<tr><td>Enter Value in TextBox</td><td><select id="ddlSample"><option value="A">A1</option><option value="B">B1</option><option value="C">C1</option></select></td></tr>
<tr><td colspan="2" align="center"><input type="button" id="btnGetDropDownValue" value="Get DropDown Value" /></td></tr>
</table>

Any Query...!!