Women in Technology

Hear us Roar



Article:
  A Simpler Ajax Path
Subject:   Only uses the first form on a page
Date:   2005-06-15 05:45:12
From:   maYO
In your example the function formData2QueryString will always and only take the contents from the very first form on a page.


Changing two lines in that function would make it more modular:


function formData2QueryString(formName) {
var docForm = document.forms[formName];
.
.
.


So the only thing left to do is call that function and passing it the name of the form as argument.

Full Threads Newest First

Showing messages 1 through 1 of 1.

  • Only uses the first form on a page
    2005-06-15 20:54:11  fleegix [View]

    Oops, sorry -- looks like the downloadable version has a slightly older version of the function. The version used as the example in the article is more up-to-date one where the form reference is passed into the function as a variable.

    That lets you use the function with forms in other frames or windows, like this:

    var openerForm = opener.document.forms['searchForm'];
    var strPostData = formData2QueryString(openerForm);


    I'll update the code in the downloadable file. Thanks for catching that.