hi,
i'm trying to set a form value via an external js file. i don't know
javascript extremely well but i do know programming in general. anyway,
i thought this would be as easy as having a javascript file saved as
.js, and clicking it when i get to the page where i would like to set
the form value, with a code that looks like this -
document.form[0].myTextBox = "Search Term";
.. if i click on this though, i get the error "document not defined."
can anyone help? as a concrete example, can someone show me the code
to, say, set the search textbox to the value "javascript" on
google/yahoo with said javascript file?
thank you thank you!
dan matthew
web.dev - 30 Sep 2005 19:34 GMT
> hi,
> i'm trying to set a form value via an external js file. i don't know
[quoted text clipped - 4 lines]
>
> document.form[0].myTextBox = "Search Term";
It's plural:
document.forms[0].myTextBox = "Search Term";
> .. if i click on this though, i get the error "document not defined."
> can anyone help? as a concrete example, can someone show me the code
[quoted text clipped - 4 lines]
>
> dan matthew
dan_matthew - 30 Sep 2005 21:56 GMT
Thank you for replying. I tried this, changing it to -
document.forms[0].myTextBox.value = "Search Term";
... but I'm still getting the error message 'document' is undefined.
To add a little info in case it's relevant, what I do is I go to the
page where the text box is, then click on the javascript file which is
set as a favorite.
Any help will be much appreciated!