Forum Moderators: open

Message Too Old, No Replies

Checking a form field exists

         

ASPhopeful

1:51 pm on Sep 28, 2004 (gmt 0)

10+ Year Member



Hi All,

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)
}

ASPhopeful

2:39 pm on Sep 28, 2004 (gmt 0)

10+ Year Member



Fixed it using:

=======================

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)

}

Rambo Tribble

2:55 pm on Sep 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could it be because fid isn't incremented if the test evaluates to true?