The actual cause is that
1 document.write(fname);
-- fname exists (form name passed to function)
2 document.write(document.forms.wheres.wherefield1.name);
-- does not exist. use document.wheres.wherefield1.name or
document.forms["wheres"].wherefield1.name
-- forms become a child node under the doument node, the reference is by the
form name (if assigned) or by index (see below)
3 document.write(document.forms[0].wherefield1.name);
-- does not exist. forms[0] is not created, try forms[1].
using document.write does not wipe out the rest of the page... but depending
on when it's envoked, the stuff may not have been created yet (ie. a call is
made to a procedure that is in the process of being given to the browser to
figure out).
HTH, Cam
-----Original Message-----
Date: Mon, 12 Mar 2001 09:42:07 -0000
From: "Windle, Kevan" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: RE: Javascript: Tearing my hair out
Thanks fro all the responses. And thanks Andy that explained why my testing
for the problem wouldn't work and that let me look past that and try another
way round it. Plus its Monday morning and everything seems so much easier.
-----Original Message-----
From: Andy Ewings [mailto:[EMAIL PROTECTED]]
Sent: 08 March 2001 17:15
To: CF-Talk
Subject: RE: Javascript: Tearing my hair out
Kevin
I may be wrong but as soon as you execute a document.write it anhialates the
page i.e. the form no longer exists. You have to use Javascript layers or
frames to overcome this.
A
-----Original Message-----
From: Windle, Kevan [mailto:[EMAIL PROTECTED]]
Sent: 08 March 2001 17:03
To: CF-Talk
Subject: Javascript: Tearing my hair out
I'm using IE5. Trying to do something really simple in javascript. The
problem I'm having is this. I can reference a form element with inline code.
So passing this variable to a function like this works:
<input
ondblclick="resetwhereboxes(this.value,3,document.forms.wheres.wherefield1.n
ame)" type="text" size="10" name="wherefield1">
then in the function:
<SCRIPT type="text/javascript" language="JavaScript1.2"><!--
function resetwhereboxes(fname){
1 document.write(fname);
2 document.write(document.forms.wheres.wherefield1.name);
3 document.write(document.forms[0].wherefield1.name);
}-->
</script>
line 1 works. But line 2 and 3, give the error messages claiming there is no
such object.
Anyone seen anything like this?
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists