Forum Moderators: open

Message Too Old, No Replies

referencing a form without (this.form)

         

mylungsarempty

5:03 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



how would i refer to a form when using javascript instead of using (this.form)?

e.g. <input type="button" value="calculate" onClick="e000001(this.form)">

korkus2000

6:04 pm on Mar 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.formname

dcrombie

6:55 pm on Mar 3, 2004 (gmt 0)



or

document.forms[0]
document.forms[1]
...

or

document.forms["formName"]

mylungsarempty

7:17 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



when i try document.formname or document.forms['formname'] it doesn't work.

Do i name the form using id="formname" or name="formname"?

I tried both, and neither way works for me. The only way i am able to reference the form is with document.forms[0]

which isn't a really big deal.. but it would be nice to figure out what i'm doing wrong.

korkus2000

8:41 pm on Mar 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



post the form tag.

mylungsarempty

8:53 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



<FORM id="asdf" name="asdf">

not a whole lot going on there =)

korkus2000

8:57 pm on Mar 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does the e000001 function look like?

mylungsarempty

9:23 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



well since that was originally posted, the e000001 function has been changed to the loop function, seen here:

function loop(){
for (var i = 0; i <= 48; i++) {
var arg = "document.forms["+i+"]";
calculate(arg);
}
}

In the other thread i have going, i end up with a problem with this loop function. Like i said: document.forms[0] works fine... but when i use the loop function to send this argument to the calculate function, i get an error. When i send the argument directly to calculate(arg) from the submit button, the script runs smoothly. There is some issue with the loop function.