473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem with simple array loop

3
I can't figure out why I cant get this simple loop to work. I'm using it to validate a form. I thought I could put the required field names in an array, loop through the array and have the it check each field. My Firebug error states that 'document.user_reg.check' is invalid. I figure it should read as 'document.user.c_fname.value' for example.

Expand|Select|Wrap|Line Numbers
  1. var check=new Array("c_fname","c_lname","c_title","c_org","c_email","c_email2","c_phone","c_password","c_password2");
  2. for(var i=0; i < check.length;i++){
  3.      if(document.user_reg.check[i].value==null || document.user_reg.check[i].value==''){
  4.           document.user_reg.check[i].className='error';missing++;
  5.      }    
  6. }
  7.  
Apr 2 '08 #1
3 1595
acoder
16,027 Expert Mod 8TB
Use the form's elements array:

Expand|Select|Wrap|Line Numbers
  1. document.user_reg.elements[check[i]]...
Apr 3 '08 #2
eDaddi
3
Well I feel stoopid.

Thanks Acoder.
Apr 3 '08 #3
acoder
16,027 Expert Mod 8TB
No worries. Glad it helped set you on your way.
Apr 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: exekutive | last post by:
I've been wrestling with this programming problem for some time now, so I thought I'd put it up for discussion. I'm trying to design a Mask function. See if you can figure out a code for it... ...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
2
by: Brian Blais | last post by:
Hello, I am trying to translate some Matlab/mex code to Python, for doing neural simulations. This application is definitely computing-time limited, and I need to optimize at least one inner...
23
by: AndersWang | last post by:
Hi, dose anybody here explain to me why memset would be faster than a simple loop. I doubt about it! In an int array scenario: int array; for(int i=0;i<10;i++) //ten loops
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.