![]() |
|
|
+ Search |
![]()
|
Jul 13th, 2000 22:12
unknown unknown, Bruce Anwyl
The following shows how to embed a single variable value from server
code and a technique for creating an array with 3 columns. It is used to
populate a dynamic list box based on a selection made from another
without making trips to the server.
It is only an extract but I hope it helps.
<script language="javascript">
// Declaring Debug variable
var javaDebug = "<%=bDebug%>";
var thisDoc;
// Create an array of Job Categories
var arrJobCategory = new Array;
// Create a Job Category element
function JobCategory(jobGroupID, jobCategoryID, jobCategoryName)
{
this.jobGroupID = jobGroupID;
this.jobCategoryID = jobCategoryID;
this.jobCategoryName = jobCategoryName;
}
//
// Update the Job Categories in the Select object
// based on the current Job Group.
//
function refreshJobCategories()
{
var option;
var jobCategoryID;
var j;
var i;
i=0;
//
// Clear the drop down list of it's current values
//
while (frmCategoryReport.cboJobCategory.length != 0)
{
frmCategoryReport.cboJobCategory.remove(0);
}
//
//Get the Job Group ID
//
jobGroupID = frmCategoryReport.cboJobGroup.value;
//Add a blank field
/*
option = document.createElement("OPTION");
option.value = 0;
option.text = '';
document.forms(0).cboJobCategory.add(option);
*/
for (i = 0; i < arrJobCategory.length; i++)
{
if (arrJobCategory[i].jobGroupID==jobGroupID)
{
option = document.createElement("OPTION");
option.value = arrJobCategory[i].jobCategoryID;
option.text = arrJobCategory[i].jobCategoryName;
frmCategoryReport.cboJobCategory.add(option);
}
}
//
// Make the first item in the list the default selection.
//
frmCategoryReport.cboJobCategory(0).selected = true;
frmCategoryReport.hdnJobCategory.value =
frmCategoryReport.cboJobCategory(0).outerText
}
//
// Fill in the Block array
//
<%
If Not rstJobCat.Eof Then
i = 0
While Not rstJobCat.EOF
Response.write "arrJobCategory[" & i & "] = new
JobCategory(" &
rstJobCat(0) & ", " & rstJobCat(1) & ", '" & rstJobCat(2) & "')" &
vbCrLf
i = i + 1
rstJobCat.MoveNext
Wend
End If
rstJobCat.Close
set rstJobCat = Nothing
%>
© 1999-2004 Synop Pty Ltd