Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-02-2010
Member
 
Join Date: Aug 2006
Posts: 300
How to access form objects of multiple forms in JavaScript?

I am very new to the JavaScript. I have started doing the JavaScript before the couple of weeks. I have done many basic scripting. I know to access form objects of the single form. But I don't know same thing when multiple forms are considered. So please anyone can tell me how to access form objects of multiple forms in JavaScript. Help me as soon as possible.!!
Reply With Quote
  #2  
Old 07-02-2010
Member
 
Join Date: Mar 2008
Posts: 349
Re: How to access form objects of multiple forms in JavaScript?

You should know one thing which is very basic. When you want to access a form through JavaScript, you will need to obtain a reference to the form object. You can do this by using the method called getElementById. Lets take an example, form with the id attribute "intro_frm", you could access the form in the following way :
Code:
var oForm = document.getElementById('intro_frm');
Hope you got the basic point of the using the getElementById method.
Reply With Quote
  #3  
Old 07-02-2010
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: How to access form objects of multiple forms in JavaScript?

I would like to suggest you that before going for the coding you should clear the concept. Once your concept is cleared you can access form objects from any number of forms. If you want to access multiple Forms through Javascript, you should use the this.form property. If you pass this.form to the onClick event handler of a form button, this function would get the reference to the form object. Just glance at the following code :
HTML Code:
<form name ="webpages_load" action="#">
Page Title: <input type="text" name="page_title" size="35">
Page URL: </label><input type="text" name="page_url" size="120">
Tags (comma separated): <input type="text" name="tags_list" size="40">
<input type="button" name="submit" value="Save Bookmark" onclick="showElements(this.form);">
</form>
Reply With Quote
  #4  
Old 07-02-2010
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to access form objects of multiple forms in JavaScript?

You can also access multiple Forms using the document object's forms collection. The property named forms which is a javascript array that holds references to all the form objects on the page is the property of the document object of a web page. For example, if you are having two forms, "submit_bill" and the other "submit_tax" which are appearing on a web page in this order, then you can access the form named "submit_tax" in the following two ways :
Quote:
var oForm = document.forms[1]; OR
var oForm = document.forms["submit_tax"];
Reply With Quote
  #5  
Old 07-02-2010
Member
 
Join Date: Nov 2008
Posts: 996
Re: How to access form objects of multiple forms in JavaScript?

The following code implements the function by passing the names of the two forms. Here is the code for that :
HTML Code:
<a href="#" onClick=" javascript: copyFormElementToElementOfDifferentForm('submit_bill', 'submit_tax', 'site_cat', 'tags_list');"
>Copy site_cat element value of the first form to the input field named "tags_list" of the second form</a>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to access form objects of multiple forms in JavaScript?"
Thread Thread Starter Forum Replies Last Post
Delphi, Multiple Forms?! alex198555 Software Development 1 28-07-2010 11:26 AM
VB 2008 - MDI child forms - How do I set a form as a MDI child form emaduddeen Software Development 2 27-04-2010 04:22 PM
Php form with javascript Solaris Software Development 3 30-11-2009 02:22 PM
How to Automatically access the fields of an Access 2007 forms Corona Software Development 3 25-06-2009 12:54 PM
How to add forms Dynamically with JavaScript Neil'o Software Development 3 12-03-2009 01:12 PM


All times are GMT +5.5. The time now is 10:11 PM.