HI,
I have a form that is dynamically generated. I have no problem with the form that works fine, but now I want to check if a user has filled out the information. A small piece of code is here when the form is made.
while (i<something)
{
heightInput.setAttribute("id","");
heightInput.id="itemHeight_"+i;
heightInput.setAttribute("name","");
heightInput.name="itemHeight_"+i;
i++;
}
so now I have names for my input fields of itemHeight_0, itemHeight_1 and so on.
I now want to check these when they are submitted, I have tried this below but of course it is not seeing itemName_+a; as the fieldname. I could pull all the elements by tag and then go through the array checking these, but I have other text boxes on the form that that would be difficult. Anyone got any ideas? I don't know how many of these text boxes will be generated so I need an automated approach.
a=0;
while(a<numberItems)
{
//the form has already been got by element id and stored as theForm.
var setName='itemName_'+a;
alert(setName);
if (theForm.setName.value=='')
{
alert('name not set');
hasError=true;
sError += " Please xxx.\n";
}
a++;
} // while
Edit/Delete Message