Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / September 2005



Tip: Looking for answers? Try searching our database.

Setting form values with external .js file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dan_matthew - 30 Sep 2005 18:49 GMT
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!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.