Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.form has no properties (but it does!!) 1

Status
Not open for further replies.

LTeeple

Programmer
Aug 21, 2002
362
CA
Hi all,
I am getting the ambiguous message "document.form has no properties". (But it does!)

Here's my (relevant) HTML code:
Code:
...
<body onLoad="getTimes(document.form.edit);">
<form name="edit" method="post" action="save.php?recid=9&tableid=18" onSubmit="return CheckForm(this)">
...// all sorts of elements with values...
</form>

Here's my (relevant) Javascript code:
Code:
function getTimes(myForm){
 //all sorts of javascript code to populate drop-down lists
}

When I run the page, the error I get in the Javascript console is: Error: document.form has no properties

Can someone explain to me what I did wrong?
[hairpull3]
Thank you!


[cheers]
Cheers!
Laura
 
looks like you are referencing the form incorrectly somewhere in your code, you should be using something like :

document.edit or
myForm

to get access to the forms elements, if you can post more of your Javascript we should be able to spot the offending code.

Also if you run it in Firefox you get a more detailed error message which may lead you to the exact line.
 
>document.form.edit
should read:
[tt]document.form[red]s[/red].edit[/tt]
or equivalently shortened to:
[tt]document.edit[/tt]
 
Hi ggriffit,
I am using firefox, it doesn't even show exact line. the ONLY place i use the line 'document.form.edit' is in the body onLoad event.

In the javascript function getTimes(myForm), I refer to the form as:
myForm.elements["elementname"].whatever... (whatever is dependent on what I'm doing of course).

So:
Relevant HTML code: (edit.php)
Code:
<body onLoad="getTimes(document.form.edit);">
<form name="edit" method="post" action="save.php?recid=10&tableid=18" onSubmit="return CheckForm(this)">
<select name="time1" onChange="populateNext(this.form,this.selectedIndex,'time1');"></select>
<select name="time2" onChange="populateNext(this.form,this.selectedIndex,'time2');"></select>
<select name="time3" onChange="populateNext(this.form,this.selectedIndex,'time3');"></select>
</form>

Relevant Javascript code: (edit.php)
Code:
function getTimes(myForm) {
  myForm.elements["time1"].options.length=0;
  myForm.elements["time1"].options[0] = new Option("Choose a time: ",0);
  myForm.elements["time2"].options.length=0;
  myForm.elements["time2"].options[0] = new Option("Choose a time: ",0);
  myForm.elements["time3"].options.length=0;
  myForm.elements["time3"].options[0] = new Option("Choose a time: ",0);
}

Obviously there's more HTML and javascript to that, but I'm sure my problem is using the line: document.form.edit in the BODY's onLoad event. I just don't know why. [hairpull3]

[cheers]
Cheers!
Laura
 
tsuji ,

Thank you, that fixed it.

So simple!

... Looks like someone has a case of the Mondays.
~Office Space


[cheers]
Cheers!
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top