Forum Moderators: open
I have a form which is dynamically generated. I need my popup window to determine what a form field is called. It will always be present and will take the format:
FlipchartDataList__ctl?_frmCategoryID
Where the questionmarks are a number below 100.
I am using the following javascript to check whether the form field is present and return the number if it is. However, my code is telling me it is always present at 0. I have checked the source code and this is not the case. Can someone please spot my error.
Many Thanks.
H.
=================
function SelectCat(categorycode) {
var fid = 0;
var exitwl = false;
var fieldtocheck = "window.opener.document.forms[0].FlipchartDataList__ctl" + fid + "_frmCategoryID";
while (exitwl == false)
{
if (null == fieldtocheck)
{
alert(fieldtocheck + " is null");
fid++;
}
else
{
if ("undefined" == fieldtocheck)
{
alert(fieldtocheck + " is undefined");
fid++;
}
else
{
alert(fieldtocheck + " is present");
exitwl = true;
}
}
}
alert(fid)
}
=======================
function SelectCat(categorycode) {
var fid = 0;
var exitwl = false;
while (exitwl == false)
{
if (window.opener.document.all.item("FlipchartDataList__ctl" + fid + "_frmCategoryID"))
{
alert("window.opener.document.forms[0].FlipchartDataList__ctl" + fid + "_frmCategoryID" + " is present");
exitwl = true;
}
else
{
alert("window.opener.document.forms[0].FlipchartDataList__ctl" + fid + "_frmCategoryID" + " is null");
fid++;
}
}
alert(fid)
}