Forum Moderators: open
I'm having a problem, and it's allready a while that I'm dealing with it.
I'm having a (very large) form on an internal web page, and to handle that form I download it to my local machine. On my local machine, I add several functionalities in an external Javascript-file. One of the functionalities I'd like to add is one of these:
document.[i]formname[/i].setAttribute('target', "TheSecondWindow");
document.forms[1].setAttribute('target', "TheSecondWindow");
The problem is that I constantly get a runtime error: 'forms' is undefined. I'm wondering what the cause can be. Is it possible to call a form in an external JS file? Even if the JS is called in the head section of the HTML (so the script tag comes before the form tag)? Or is the HTML badly formatted? I didn't that one of those things can cause the problem, but as I'm still having the problem, I start questioning everything. ;)
A part of the JS file has allready been quoted higher. If you like more info, I can post more. And here is a part of the HTML file (I did not write it myself):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=*** -->
<HTML><HEAD><TITLE>***</TITLE><script language="JavaScript" src="name.js"></script>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type><LINK
href="***" rel=stylesheet type=text/css>
<META content="MSHTML 5.00.3502.5390" name=GENERATOR></HEAD>
<BODY>
<H1>***</H1>
<form action=/cgi-bin/name.pl method=post name=aname><INPUT name=a
type=hidden value=t> <INPUT name=sid type=hidden value=avalue> <INPUT type=submit value="avalue"> </FORM>
<form action=/cgi-bin/another.pl method=post name="theformname">
<TABLE border=1 width="100%">
<TBODY>
Regards
I tried that too before, but I didn't know that the rest of the code after the onload is executed before the whole page is loaded. I thought that execution stopped right before onload till the page is loaded, but it seems like it is not. Now I included all the necessary stuff in onload function.
Thanx, case closed!