Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if form field is on page

Status
Not open for further replies.

rkoya

IS-IT--Management
Jul 12, 2004
57
0
0
GB
Hi,

I have a number of fields that are bought in dynamically based on selection from the previous screen. How do I check to see if a certain form field is on the page or not.

thanks
 
An easy way is to use it in an if statement.
Say you are checking for a field with an ID of mytest

if (document.getElementById('mytest'))
alert('mytest exists');
else
alert('mytest does not exist');


At my age I still learn something new every day, but I forget two others.
 
Something like this:
Code:
if (document.getElementsByName('your element name here').length > 0)
  {
  //your code here if element exists
  }

Lee
 
There's almost always more than one way to accomplish something, as you can see. :)#

Lee
 
Thanks worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top