Thread: Javascript
View Single Post
12-18-2005, 02:50 AM
#1
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old  Javascript

I have a validation section in some of my code. It's pretty simple, but the problem is there is 10 sections to it. I don't want to have to write out all 10 sections, I just want to write out one and get a loop to do the rest.

Is there any way to do this?

Code:
			if(document.RealEstate.INSPECTION_TIME_D1.value != "----") {
			
					alert("Error!\nYou have started Inspection #1 but you have not completed it.");
					return false;
				}			
			}
I want something like

Code:
for(x = 0; x !=; x++) {
if(document.RealEstate.INSPECTION_TIME_D+x+.value != "----") {
			
					alert("Error!\nYou have started Inspection #" + x + "but you have not completed it.");
					return false;
				}			
			}
}
Notice in the if statement, the INSPECTION_TIME_D is +x+ not 1. I want the X to replace the number.

I hope this makes sense, I'm sure its easy to do I'm just not sure how to do it.