Forum Moderators: open

Message Too Old, No Replies

reference to a form

         

gergoe

11:49 pm on May 15, 2004 (gmt 0)

10+ Year Member



I'm wondering what's the best way to make a reference to a form on a page, where I can't be sure about the content of the forms collection?

Let's assume I have a header file which is included sometimes into the pages, but sometimes not, and there's a standalone form in the header. But the page itself is containing a form also, but I want to check some fields upon submitting. I use always the document.forms[#] way of referencing for this purpose, but in this case I can't use it, since I don't know the sequence of the forms.

What is the best and safest way (fool- and browser-proof) for this?

BlobFisk

12:40 am on May 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use a form name:

<form name="someName" ...>

Then reference it:

document.someName.

HTH

gergoe

1:02 am on May 16, 2004 (gmt 0)

10+ Year Member



i have my doubts about this one, looong time ago i had serious problems referencing to a form like this with ie and netscape, did this changed in the last couple of years?

Well, i'm quite old-fashined in a way, and since the forms collection was working always, so i just did not checked the other possibilities...

BlobFisk

12:34 pm on May 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've always use the name reference rather than the array entity and have never had a problem... Strange!

Have you run some tests to see if the name reference is ok on your pages?

gergoe

1:01 pm on May 16, 2004 (gmt 0)

10+ Year Member



I just did not used names to reference to them in the last couple of years; last time I tried was about when the microsoft released their brand new browser the internet explorer 3.01, and at time the netscape (4.x) was the top of the browsers...

Does the "other" browsers like opera, mozilla supports this way of referencing?

Thanks anyway;

Rambo Tribble

1:02 pm on May 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have also found the name reference reliable across platforms. The syntax must be rather precise, however, and maybe that's where your problems originated before, gergoe.

gergoe

1:06 pm on May 16, 2004 (gmt 0)

10+ Year Member



You might be right; at that time I just started with the JavaScript (and web page authoring in general), could be that I was just too quick to say that it is not reliable, meanwhile I did not used it carefully. Pity, that I'm still afraid to use it ;-)

Thanks guys;