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

Q1591 How can I find out what kind of object a particular form field is?

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

Q1591 How can I find out what kind of object a particular form field is?

In Netscape Navigator 3+ and Internet Explorer 4+ (i.e. JavaScript 1.2) you can interrogate the form field's type property:

<form name="myForm">
<input type="text">
<input type="radio">
<input type="checkbox">
</form>

<script language="JavaScript"><!--
var o = '';
if (document.myForm.elements[0].type)
  for (i=0;i < document.myForm.elements.length;i++) 
    o += document.myForm.elements[i].type + '\n';

alert(o);
//--></script>

Feedback on 'Q1591 How can I find out what kind of object a particular form field is?'


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.