Results 1 to 5 of 5

Thread: How to access form objects of multiple forms in JavaScript?

  1. #1
    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.!!

  2. #2
    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.

  3. #3
    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>

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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 :
    var oForm = document.forms[1]; OR
    var oForm = document.forms["submit_tax"];

  5. #5
    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>

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,921,026.64776 seconds with 16 queries