Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Setting form values with external .js file

Reply
Thread Tools

Setting form values with external .js file

 
 
dan_matthew
Guest
Posts: n/a
 
      09-30-2005
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

 
Reply With Quote
 
 
 
 
web.dev
Guest
Posts: n/a
 
      09-30-2005

dan_matthew wrote:
> 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";


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
> to, say, set the search textbox to the value "javascript" on
> google/yahoo with said javascript file?
>
> thank you thank you!
>
> dan matthew


 
Reply With Quote
 
 
 
 
dan_matthew
Guest
Posts: n/a
 
      09-30-2005
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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting values of properties in user controls from the parent form Mark Rae ASP .Net 3 05-12-2006 01:33 PM
setting form values via external js file ... trying to use document.form.filed.value jason@cyberpine.com Javascript 3 11-08-2004 02:05 PM
Setting form element values in an exception handler Sky Fly ASP .Net 2 04-09-2004 07:44 AM
Setting form element values in an exception handler Sky Fly ASP .Net Web Controls 2 04-09-2004 07:44 AM
localizing web form without setting values programmatically Philipp Sumi ASP .Net 2 07-23-2003 09:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57