Wednesday, November 23, 2016

Read value of controls in SharePoint form

Hi folks,

I got a pre-defined function which helps to read value of controls in SharePoint form. To find a control in SharePoint from client side Javascript we normally use the getTagFromIdentifierAndTitle function.

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;
}
Tag is the html tag used to define the control, Identifier is the type of the control and title is the name of the control. Below are basic tag and identifiers of the server side controls.
Control                 Tag               Identifier
Panel                 div  
Label                 label  
Button                 input               button
Link Button         href  
Hyperlink         href  
Image Button         input               image
Textbox                 input               text
Textbox (Password) input               password
Textbox (Multiline) Input               textarea
DropDownList         select  
Listbox                 select  
RadioButton         input               radio
Checkbox         input               checkbox
File                 input               file

Please find the link below for more information
https://workflowssimplified.wordpress.com/2011/09/15/gettagfromidentifierandtitle-function/ 


No comments:

Post a Comment