append a count number to a javascript get value statement
depending on how many records are entered each is labeled diffently using the count varable so there many be any number of records which are named i+comphousename
is there a way to append the value of i to the if statement so that i may check if it is null?
for (var i = 0; i < document.myForm.count.value; i++)
{
if(document.myForm.comphousename.value =="")
{
window.alert('You must enter a House Name / Number');
return;
}
}
[747 byte] By [
h1400046a] at [2007-11-26 17:56:02]

# 1
for (var i = 0; i < document.myForm.count.value; i++)
{
if(document.myForm.getElementById("comphousename"+i).value == "")
{
window.alert('You must enter a House Name / Number');
return;
}
}
Please try as in the code..you should be able to validate.
# 2
if i do this:
for (var i = 0; i < document.myForm.count.value; i++)
{
if(document.myForm.getElementsByName(i+"comphousename").value == "")
{
window.alert('You must enter a House Name / Number');
return;
}
}
it says: object doesnt support property or method
if i remove the myForm part then it doesnt error, but it also still doesnt work. if i cange it to ==null it causes the error to appear weather there is data or not?
# 3
i could not give you the sufficient details last time..
use an array to check the values of all the rows created.
myOld_Array = new Array(No_Of_Rows_Created);
for(var i=1; i<= No_Of_Rows_Created ; i++)
{
myOld_Array =document.getElementById("comphousename"+i).value;
if(myOld_Array == null)
{
do neccesary
}
}
Use array index i to differenciate the elements.