Hi, I am trying to use Javascript to check a form which is named dynamically but my code isn't working. My cgi script creates a HTML page which contains forms named form0, form1, form2 etc. Each form contains a field named type_id, a field named budget and a field named start_date.
Here is my Javascript function:
function nextCheck(tot)
{
var missinginfo = "";
if (document.forms[tot].type_id.value==""
{
missinginfo += "\n Budget Type";
}
if (document.forms[tot].budget.value==""
{
missinginfo += "\n Budget";
}
if (document.forms[tot].start_date.value==""
{
missinginfo += "\n Start Date";
}
if (missinginfo != ""
{
missinginfo = "Please fill in the following:\n"+missinginfo;
alert(missinginfo);
return false;
}
else
{
return true;
}
}
I am calling the function from the submit button like this:
onClick="return nextCheck(form$i);"
(where $i is a number generated by the cgi script)
Can anyone tell me where I'm going wrong? Thanks.
Here is my Javascript function:
function nextCheck(tot)
{
var missinginfo = "";
if (document.forms[tot].type_id.value==""
{
missinginfo += "\n Budget Type";
}
if (document.forms[tot].budget.value==""
{
missinginfo += "\n Budget";
}
if (document.forms[tot].start_date.value==""
{
missinginfo += "\n Start Date";
}
if (missinginfo != ""
{
missinginfo = "Please fill in the following:\n"+missinginfo;
alert(missinginfo);
return false;
}
else
{
return true;
}
}
I am calling the function from the submit button like this:
onClick="return nextCheck(form$i);"
(where $i is a number generated by the cgi script)
Can anyone tell me where I'm going wrong? Thanks.