Arc
05-14-2003, 08:01 PM
Hi, I have a peice of code that i need to loop through some dynamically created file buttons.
I have no idea how many buttons will be added to the form but they are all named in sequential order i.e. Image0,Image1,Image2,ect...
So what i am trying to do is create a validation script to check that all of these file buttons have a value. I am using a For Loop looping through as many times as there are file buttons. I know how many because they entered it on the last page and the variable is stored in a hidden input box.
The problem is document.form doesnt seem to accpet a variable as a control name even though the variable has the same value as the name of the control. Example:
var TheImage = "Image"+Counter;
if(document.form.TheImage.value == "")
The variable 'TheImage' holds the Value Image0, but the script doesnt work when the variable is in place of the control name. If i manualy enter the control name like so
if(document.form.Image0.value == "")
then the script works.
So how do i use a variable as a control name to validate my fields? Or is there another way to validate the fields?
Thanks!:D
I have no idea how many buttons will be added to the form but they are all named in sequential order i.e. Image0,Image1,Image2,ect...
So what i am trying to do is create a validation script to check that all of these file buttons have a value. I am using a For Loop looping through as many times as there are file buttons. I know how many because they entered it on the last page and the variable is stored in a hidden input box.
The problem is document.form doesnt seem to accpet a variable as a control name even though the variable has the same value as the name of the control. Example:
var TheImage = "Image"+Counter;
if(document.form.TheImage.value == "")
The variable 'TheImage' holds the Value Image0, but the script doesnt work when the variable is in place of the control name. If i manualy enter the control name like so
if(document.form.Image0.value == "")
then the script works.
So how do i use a variable as a control name to validate my fields? Or is there another way to validate the fields?
Thanks!:D