Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

how to get all elements of a page in javascript

how to get all elements of a page in javascript

 
Post new topic   Reply to topic     Forum Index -> JavaScript, DHTML, AJAX
View previous topic :: View next topic  
Author Message
sujimert



Joined: 23 Jan 2007
Posts: 5

PostPosted: Fri Dec 05, 2008 2:32 pm    Post subject: how to get all elements of a page in javascript Reply with quote

Hi
I want to get all elements of form of HTML page through JavaScript. Which is inside of body tag of HTML page.
Back to top
View user's profile Send private message
turner



Joined: 08 Dec 2008
Posts: 2

PostPosted: Fri Dec 12, 2008 2:42 pm    Post subject: Reply with quote

Use element property of document in javascript to get all field value and name in form
No matter, it is in body or outside

if form tag inside have field we can get it


Code:
 var i=document.formName.elements.length;
  var e=document.formName.elements;

  var name=new Array();
  var value=new Array();
 
  for(var k=0;k<i;k++)
  {
        value[j]=document.formName.elements[k].value;
        alert("value :"+value[j]);
        name[j] =document.formName.elements[k].name;
        alert("name:"+name[j]);
  }
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> JavaScript, DHTML, AJAX All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack