By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

setting form values via external js file ... trying to use document.form.filed.value

P: n/a
I have a function that <body onload=..> sets some form values. However
when i execute that functionf from external js file, i get erorrs and
it dont work.

The function sets the fields via

document.forname.fieldname.value = xx;

I would imagine document no longer applies since external js file. How
can i do this from an external js file.

thanks.
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 7 Nov 2004 08:27:23 -0800, <ja***@cyberpine.com> wrote:

[snip]
document.forname.fieldname.value = xx;

I would imagine document no longer applies since external js file.
Not at all. The script will act exactly as it would had you pasted the
contents within a SCRIPT element.
How can i do this from an external js file.


As you normally might.

Could you show an example, preferably presenting a small demonstration
somewhere on the Web.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

P: n/a
Thanks for response.

I found my bug. I had left the <script language> tag in the .js file
.... and apparently you can't have html in an external js file so the
function was not being found.

Incidently, what's the best way to expand on these javascript errors
you might get at the bottom of the browser screen. Any way to get more
detail, and maybe a line number or something. I'm using IE 6.0.

Thanks.
Jul 23 '05 #3

P: n/a
On 8 Nov 2004 05:45:04 -0800, <ja***@cyberpine.com> wrote:
Thanks for response.
You're welcome.
I found my bug. I had left the <script language> tag [...]
The language attribute is deprecated, by the way. It has been for over six
years. The script type should be specified using the type attribute:

<script type="text/javascript">
... and apparently you can't have html in an external js file so the
function was not being found.
No, you certainly can't. The external file should only contain content
that is valid for the script language.
Incidently, what's the best way to expand on these javascript errors you
might get at the bottom of the browser screen. Any way to get more
detail, and maybe a line number or something. I'm using IE 6.0.


You can add the Microsoft Script Debugger, but I found it cumbersome to
use. I would recommend using another browser, which is generally a good
idea for Web development anyway as you don't fall into the trap of using
Microsoft-only "features"[1].

Opera's Javascript console automatically includes a trace through your
script that's very useful in determining what went wrong, where. The
development tools that come with the Mozilla Browser Suite and Mozilla
Firefox are also better than the IE console.

Opera <URL:http://www.opera.com/>
Mozilla <URL:http://www.mozilla.org/>

Mike
[1] Unless you're developing for a Microsoft-only environment, of course.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.