Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1701 How can I get the value of a text input field without using the name of the field?

irt.org | Knowledge Base | JavaScript | Form | Q1701 [ previous next ]

Q1701 How can I get the value of a text input field without using the name of the field?

Use its position within the elements array. For example, the following retrieves the value of the 2nd element:

<form>
<input type="button" value="show value" onClick="alert(this.form.elements[1].value)">
<input type="text" value="Hello world">
</form>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.