...

View Full Version : How to pass auto numbered objects in a function



guyInATL
11-02-2004, 08:41 PM
Hi All

I have a .jsp page which pulls up multiple workshops data for editing.

The workshop array is looped and each description, presenter, seats textbox is also looped like

txtPresenter1
txtDesc1
txtSeats1

txtPresenter2
...

i have a 3rd party validation script
that takes in the format

form.addValidation("txtPresenter", required)
form.addValidation("txtDesc", required)


Now is there some way i can loop and construct a validation function for each set of text boxes

or better i am thinking i should have 1 global validation function for each presenter, description and so on but how to implement it ?

Many thanks
R

Kor
11-03-2004, 08:58 AM
i don't quite understood your problem... You wanna use validation functions for group of fields? In this case nest them in divs and loop the div's childs

function validate01(){
var fields=document.getElementById('d01').getElementsByTagName('input');
for(var i=0;i<fields.length;i++){
if(...negative codition...){
alert('message');
fields[i].focus();
return false;
}
}
}
function validate02(){
var fields=document.getElementById('d02').getElementsByTagName('input');
for(var i=0;i<fields.length;i++){
if(...negative codition...){
alert('message');
fields[i].focus();
return false;
}
}
}
..
function validate(){
validate01();
validate02();
}
...
...
<form onsubmit ="return validate()">
<div id="d01">
...group of fields here
</div>
<div id="d01">
....group of fields here
</div>
<input type="sumbit" value="submit">
</forms>
...
...
or something like that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum