Article ID: 195189
Article Last Modified on 7/2/2004
<SCRIPT LANGUAGE=javascript RUNAT=Server>
var arrChk = null;
var fDebug = 1;
</SCRIPT>
<%
for (var nIndex = 0; nIndex < thisPage.getNumFields(); nIndex++)
{
//cycle through the arrChk array of check box script object
//and call the display method to output to page
arrChk[nIndex].display();
Response.Write('<br>');
}
if (fDebug)
{
for (var nIndex = 0; nIndex < thisPage.getNumFields(); nIndex++)
{
Response.Write('Value[' + nIndex + '] = ' +
arrChk[nIndex].getChecked() + '<br>');
}
}
%>
<!--#INCLUDE FILE="_ScriptLibrary/CheckBox.ASP"-->
<SCRIPT ID=serverEventHandlersJS LANGUAGE=javascript RUNAT=Server>
function thisPage_onenter()
{
var intNumCheck = 5;
//1=debug mode
//2=no debug
fDebug = 1;
if (thisPage.firstEntered == true)
{
//specifying the number of check boxes to create
//then creating them
thisPage.setNumFields(intNumCheck);
CreateCheckboxes(false);
}
}
function _ChkInit(nIndex)
{
arrChk[nIndex].setCaption('DynChk' + nIndex);
}
function CreateCheckboxes(fRestore)
{
var nChk = thisPage.getNumFields();
arrChk = new Array();
//create the check box script objects and throw them
//into arrChk array to be used later
for (var nIndex = 0; nIndex < nChk; nIndex++)
{
arrChk[nIndex] = CreateCheckbox('DynChk' +
nIndex, '_ChkInit(' + nIndex + ')', null);
//if the form was submitted we need to restore the
//state of the check boxes
if (fRestore)
arrChk[nIndex]._restoreState();
}
}
function Button1_onclick()
{
CreateCheckboxes(true);
}
</SCRIPT>
Keywords: kbhowto kbscript kbctrl kbremoteprog KB195189