How to Get the Names of Fields in SharePoint Lists in JavaScript
The SharePoint server software lets you customize the intranet user interface using the JavaScript language. The JavaScript language has a "getElementsByTagName" function that gets a list of field names associated with a tag name. For instance, if you have a list of text boxes, this function gets the text box names. You use this function to get a list of field names in a SharePoint custom page.
Instructions
-
-
1
Open the SharePoint editor and open the page you want to edit to view its fields and HTML code.
-
2
Click the "Code View" tab to view the HTML. At the top of the page, add the following "script" tag in the head tags of the code:
<script type="text/javascript" > </script>
-
-
3
Add the JavaScript code to retrieve a list of field names for a specific tag group. For instance, the following code gets a list of text boxes for a Sharepoint form:
var fields = document.getElementsByTagName("input");
-
4
Display the input field values. The "getElementsByTagName" sends an array of values to the designated variable. In this example, the variable is "fields." The following code displays the first field value in the array:
document.write(fields[i].value);
-
1