|
SharePoint 2010 - Cascading DropDown by using JavaScript
|
|
|
|
Add the below JavaScript code to Newform/Editform :<script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(FilterItem, "sp.js"); var site; var context; var listItems; function FilterItem() { var listTitle = "Region-Site"; //var selectedCnty = $("select[title='Country'] option:selected").val(); //Get the current client context context = SP.ClientContext.get_current(); var Listobj = context.get_web().get_lists().getByTitle(listTitle); // use a standard syntax CAML query to filter your results and the fields returned if required, by adding the following, or passing parameters to the load command below var query = new SP.CamlQuery(); // You can leave out this line if you just want to return the entire list. query.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Country' LookupId='TRUE'/><Value Type='Lookup'>"+ selectedCountryID +"</Value></Eq></Where></Query></View>"); //var camlQuery = SP.CamlQuery.createAllItemsQuery(); this.listItems = Listobj.getItems(query); //alert(listItems); context.load(listItems); context.executeQueryAsync(FilterItemSucceeded, ReadListItemFailed); } // regular array (add an optional integer function FilterItemSucceeded(sender, args) { &nbs...
read more >>
|
|
|
|
|
|
|
|
|
SharePoint 2010 - Custom Validation in Newform/Editform by JavaScript
|
|
|
|
Add the below JavaScript code to the page by using SharePoint Designer, <script type="text/javascript">function PreSaveItem(){ var RegionCnt = getTagFromIdentifierAndTitle("INPUT","TextField","Region"); var SiteCnt = getTagFromIdentifierAndTitle("INPUT","TextField","Site"); if( RegionCnt.value == "" && SiteCnt.value == "") { alert("You have to enter either Region or Site."); return false; } else { return true; }}// Find a contorl in the page by using title function getTagFromIdentifierAndTitle(tagName, identifier, title) { var len = identifier.length; var tags = document.getElementsByTagName(tagName); for (var i=0; i < tags.length; i++) { var tempString = tags[i].id; if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) { return tags[i]; } } return null; }</script>...
read more >>
|
|
|
|
|
|
|
|
|
SharePoint 2010 - Model Popup Window functionality in Quick Launch link
|
|
|
|
Add the below JavaScript code in Master Page. <script type="text/javascript"> var optionsMobileDevice = { allowMaximize: true, showClose: true, dialogReturnValueCallback: refreshCallback }; function openModalWindow(URL) { optionsMobileDevice.url = URL; SP.UI.ModalDialog.showModalDialog(optionsMobileDevice); } function silentCallback(dialogResult, returnValue) { } function refreshCallback(dialogResult, returnValue) { if(dialogResult == SP.UI.DialogResult.OK) { var sourceURL = querySt('Source',optionsMobileDevice.url); window.location = sourceURL ; } } function querySt(ji,pageURL) { hu = pageURL; gy = hu.split("&"); for (i=0;i<gy.length;i++) { ft = gy[i].split("="); if (ft[0] == ji) { return ft[1]; } } } </script>Add the link in Quick Launch link :javascript:openModalWindow('http://localhost/Lists/LstFileNumber/NewForm.aspx?IsDlg=1&Source=http://localhost/Lists/LstFileNumber/');...
read more >>
|
|
|
|
|
|
|
|
|
SharePoint 2010 - Custom Save button for Newform/EditForm by JavaScript
|
|
|
|
Copy & Paste this code to Newform/Editform : <input type="button"
value="Save" name="btnSave" onclick="javascript:
{ddwrt:GenFireServerEvent('__commit;__redirect={ http://mosssrv2010:8181/SitePages/Thanks.aspx}')}"
style="width: 83px" /> Note: Replace the highlighted red color path
with current environment path. Create a ‘Thanks.aspx’ Webpart page with thanks
message and refer that URL in that place....
read more >>
|
|
|
|
|
|
|
|
|
SharePoint 2010 - Dynamic PDF Viewer by JavaScript
|
|
|
|
Copy & Paste the below JavaScript function to Content Editor Webpart: <div id="pdffile"><embed width="1000" height="800" src="/SitePages/JRSample.aspx?PageView=Shared&InitialTabId=Ribbon.WebPartPage&VisibilityContext=WSSWebPartPage#toolbar=0&navpanes=0&scrollbar=1" type="text/html; charset=utf-8"></embed> </div><script type="text/javascript">function getParameter(szName){// Get value out of supplied parametervar szUrl = window.location.search;szUrl = szUrl.toLowerCase();szName = szName.toLowerCase();var szValue = "";var nBegin = szUrl.indexOf(szName);if (nBegin != -1){szValue = szUrl.substring(nBegin + (szName.length + 1));}var nEnd = szValue.indexOf("&");if (szValue != "" && nEnd != -1){szValue = szValue.substring(0, nEnd);}return szValue;}function wmpCreate(url) {var str = "";var parampath = getParameter("TranPath");var agt = navigator.userAgent.toLowerCase();var is_ie = (agt.indexOf("msie") != -1);if (is_ie) {// create the WMP for IEstr = '<embed src="'+ parampath +'#toolbar=0&navpanes=0&scrollbar=1" width="1000" height="800"/> ';} else {// create it for FF.str = '<embed src="'+ parampath +'#toolbar=0&navpanes=0&scrollbar=1" width="1000" height="800"/>';}return str;}function pdfCreate() {document.getElementById('pdffile').innerHTML = wmpCreate();}_spBodyOnLoadFunctionNames.push("pdfCreate");</script>...
read more >>
|
|
|
|
|
|
|
|