_ Spbodyonloadfunctionnames
==================
This is an array. Javascript programmers can use SharePoint designer to edit the SharePoint page and push their own function names to this array. Then, the javascirpt function will be called during page initialization.
_ Spbodyonloadfunctionnames. Push ("myinitfunction ");
Presaveitem
==================
If you want to perform some verification before creating a list item, you need to implement a presaveitem function.
So how do we know this function?
You can view the source code of the newform. ASPX page in a browser. You will find that the onclick event of the "finish" button contains the call of this function.
<input type="button"
name="ctl00$m$g_blah_blah_blah_$diidIOSaveItem"
value="Finish"
onclick="if (!PreSaveItem())return false;
WebForm_DoPostBackWithOptions(
new WebForm_PostBackOptions(......))"
id="ctl00_m_g_blah_blah_blah_diidIOSaveItem"
accesskey="S"
class="ms-ButtonHeightWidth"
target="_self"
/>
This presaveitem function is defined in the c: \ Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template \ layouts \ 1033 \ form. js file.
//Code below is from form.js of SharePoint OOB js file
function PreSaveItem()
{
if ("function"==typeof(PreSaveAction))
{
return PreSaveAction();
}
return true;
}
How to use it? Very simple.
//Code below is from your aspx file.
function PreSaveItem() {
// Do your thing here
// .......
}
Optlosefocus (OPT)
==================
This function comes from core. js and is defined as follows:
function OptLoseFocus(opt)
{
var ctrl=document.getElementById(opt.ctrl);
if (opt.selectedIndex >=0)
SetCtrlFromOpt(ctrl, opt);
opt.style.display="none";
}
The function is to set the option of a control to the selected status.
Showdropdown (textboxid)
==================
Show the dorpdown control, defined in core. js and OWS. JS, as follows:
function ShowDropdown(textboxId)
{
var ctrl=document.getElementById(textboxId);
var str=ctrl.value;
var opt=EnsureSelectElement(ctrl, ctrl.opt);
ctrl.match=FilterChoice(opt, ctrl, "", ctrl.value);
ctrl.focus();
}
Source:
SharePoint JavaScript-page load add function: _ spbodyonloadfunctionnames
Http://blogs.msdn.com/ B /saurabhkv/archive/2009/06/22/javascript-pageload-add-function.aspx
Add JavaScript date validation into list item forms
Http://edinkapic.blogspot.com/2007/10/add-javascript-date-validation-into.html
Using JavaScript to manipulate a list form field
Http://blogs.msdn.com/ B /sharepoint/archive/2007/06/21/using-javascript-to-manipulate-a-list-form-field.aspx
============= Other JavaScript resources ================================
Http://sharepointdevwiki.com/display/public/SharePoint+JavaScript+Functions+Overview
Http://hilfiger1014.spaces.live.com/Blog/cns! B5605d7c2a738c3d! 1140. Entry