• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript and "value=" attribute of input tag.

 
Gabriel Allen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyway to use a javascript value in the value attribute of an input tag?

Ex:
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can set the value with JavaScript with some sort of action



Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer to avoid references such as forms[0] because the code may break if the form changes position on the page.

Give the form an explicit name and use it, or give the element an id and reference it directly.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
I prefer to avoid references such as forms[0] because the code may break if the form changes position on the page.

Give the form an explicit name and use it, or give the element an id and reference it directly.


Bear,

You use more than one form on a page? Geesh...lol

FYI: name is depretiated now on a form element if you care about standards!

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic