473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Troubleshooting client-side dynamic dependent list boxes

Greetings,

I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot.

I have a form with a series of dynamic dependent list boxes. Making a selection from list/box A (Qtr) selects a fiscal quarter, which then refreshes the values in list/box B (Mth), which shows the 3 months in that fiscal quarter, which then refreshes the values in list/box C (MthDate), which returns the date values for that month (e.g., 1-30).

My problem is that making the selection from list A correctly refreshes the values in list B but not with list C. Only when I physically change the option value in list B does list C refresh, but I would expect the list C values to refresh automatically when the onChange event fires upon making a selection in list A.

Here's the JavaScript code:

Expand|Select|Wrap|Line Numbers
  1. <!-- Dynamic Dependent List box Code for *** VBScript *** Server Model //--><script language="JavaScript"><!--
  2. var arrDynaList2 = new Array();
  3. var arrDL2 = new Array();
  4. arrDL2[1] = "Qtr";           // Name of parent list box
  5. arrDL2[2] = "form1";                  // Name of form containing parent list box
  6. arrDL2[3] = "Mth";         // Name of child list box
  7. arrDL2[4] = "form1";                  // Name of form containing child list box
  8. arrDL2[5] = arrDynaList2;
  9. <%
  10. Dim txtDynaListRelation2, txtDynaListLabel2, txtDynaListValue2, oDynaListRS2
  11. txtDynaListRelation2 = "Qtr"    ' Name of recordset field relating to parent
  12. txtDynaListLabel2 = "Mth_Label"    ' Name of recordset field for child Item Label
  13. txtDynaListValue2 = "Mth"        ' Name of recordset field for child Value
  14. Set oDynaListRS2 = QtrMth         ' Name of child list box recordset
  15. Dim varDynaList2
  16. varDynaList2 = -1
  17. Dim varMaxWidth2
  18. varMaxWidth2 = "1"
  19. Dim varCheckGroup2
  20. varCheckGroup2 = oDynaListRS2.Fields.Item(txtDynaListRelation2).Value
  21. Dim varCheckLength2
  22. varCheckLength2 = 0
  23. Dim varMaxLength2
  24. varMaxLength2 = 0
  25. While (NOT oDynaListRS2.EOF)
  26.  If (varCheckGroup2 <> oDynaListRS2.Fields.Item(txtDynaListRelation2).Value) Then
  27.   If (varCheckLength2 > varMaxLength2) Then
  28.    varMaxLength2 = varCheckLength2
  29.   End If
  30.   varCheckLength2 = 0
  31.  End If
  32. %>
  33.  arrDynaList2[<%=(varDynaList2+1)%>] = "<%=(oDynaListRS2.Fields.Item(txtDynaListRelation2).Value)%>"
  34.  arrDynaList2[<%=(varDynaList2+2)%>] = "<%=(oDynaListRS2.Fields.Item(txtDynaListLabel2).Value)%>"
  35.  arrDynaList2[<%=(varDynaList2+3)%>] = "<%=(oDynaListRS2.Fields.Item(txtDynaListValue2).Value)%>"<%
  36.  If (len(oDynaListRS2.Fields.Item(txtDynaListLabel2).Value) > len(varMaxWidth2)) Then
  37.   varMaxWidth2 = oDynaListRS2.Fields.Item(txtDynaListLabel2).Value
  38.  End If
  39.  varCheckLength2 = varCheckLength2 + 1
  40.  varDynaList2 = varDynaList2 + 3
  41.  oDynaListRS2.MoveNext()
  42. Wend
  43. If (varCheckLength2 > varMaxLength2) Then
  44.  varMaxLength2 = varCheckLength2
  45. End If
  46. %>
  47.  
  48. var arrDynaList = new Array();
  49. var arrDL1 = new Array();
  50. arrDL1[1] = "Mth";         // Name of parent list box
  51. arrDL1[2] = "form1";                  // Name of form containing parent list box
  52. arrDL1[3] = "Day";         // Name of child list box
  53. arrDL1[4] = "form1";                  // Name of form containing child list box
  54. arrDL1[5] = arrDynaList;<%
  55. Dim txtDynaListRelation, txtDynaListLabel, txtDynaListValue, oDynaListRS
  56. txtDynaListRelation = "CategoryID"    ' Name of recordset field relating to parent
  57. txtDynaListLabel = "MthDate"     ' Name of recordset field for child Item Label
  58. txtDynaListValue = "MthDate"        ' Name of recordset field for child Value
  59. Set oDynaListRS = MthDate         ' Name of child list box recordset
  60. Dim varDynaList
  61. varDynaList = -1
  62. Dim varMaxWidth
  63. varMaxWidth = "1"
  64. Dim varCheckGroup
  65. varCheckGroup = oDynaListRS.Fields.Item(txtDynaListRelation).Value
  66. Dim varCheckLength
  67. varCheckLength = 0
  68. Dim varMaxLength
  69. varMaxLength = 0
  70. While (NOT oDynaListRS.EOF)
  71.  If (varCheckGroup <> oDynaListRS.Fields.Item(txtDynaListRelation).Value) Then
  72.   If (varCheckLength > varMaxLength) Then
  73.    varMaxLength = varCheckLength
  74.   End If
  75.   varCheckLength = 0
  76.  End If
  77. %>
  78.  arrDynaList[<%=(varDynaList+1)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListRelation).Value)%>"
  79.  arrDynaList[<%=(varDynaList+2)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListLabel).Value)%>"
  80.  arrDynaList[<%=(varDynaList+3)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListValue).Value)%>"<%
  81.  If (len(oDynaListRS.Fields.Item(txtDynaListLabel).Value) > len(varMaxWidth)) Then
  82.   varMaxWidth = oDynaListRS.Fields.Item(txtDynaListLabel).Value
  83.  End If
  84.  varCheckLength = varCheckLength + 1
  85.  varDynaList = varDynaList + 3
  86.  oDynaListRS.MoveNext()
  87. Wend
  88. If (varCheckLength > varMaxLength) Then
  89.  varMaxLength = varCheckLength
  90. End If
  91. %>
  92.  
  93. //--></script><!-- End of object/array definitions, beginning of generic functions --><script language="JavaScript">
  94. <!--
  95. function setDynaList(arrDL){
  96.  var oList1 = document.forms[arrDL[2]].elements[arrDL[1]];
  97.  var oList2 = document.forms[arrDL[4]].elements[arrDL[3]];
  98.  var arrList = arrDL[5];
  99.  clearDynaList(oList2);
  100.  if (oList1.selectedIndex == -1){
  101.   oList1.selectedIndex = 0;
  102.  }
  103.  populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
  104.  return true;
  105. }
  106. function clearDynaList(oList){
  107.  for (var i = oList.options.length; i >= 0; i--){
  108.   oList.options[i] = null;
  109.  }
  110.  oList.selectedIndex = -1;
  111. }
  112. function populateDynaList(oList, nIndex, aArray){
  113.  for (var i = 0; i < aArray.length; i= i + 3){
  114.   if (aArray[i] == nIndex){
  115.    oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
  116.   }
  117.  }
  118.  if (oList.options.length == 0){
  119.   oList.options[oList.options.length] = new Option("Please Select",0);
  120.  }
  121.  oList.selectedIndex = 0;
  122. }
  123. function MM_callJS(jsStr) { //v2.0
  124.   return eval(jsStr)
  125. }
  126. //-->
  127. //--></script>
Here also is the body onload code...

Expand|Select|Wrap|Line Numbers
  1. <body onload="MM_callJS('setDynaList(arrDL2)');MM_callJS('setDynaList(arrDL1)')">
...and the list/menu on change codes...

Expand|Select|Wrap|Line Numbers
  1. <select name="Qtr" onchange="MM_callJS('setDynaList(arrDL2)')">
Expand|Select|Wrap|Line Numbers
  1. <select name="Mth" id="Mth" onchange="MM_callJS('setDynaList(arrDL1)')">
Whatever help someone can offer would be greatly appreciated.

Regards,

j
May 21 '09 #1
1 2930
PROBLEM RESOLVED. I figured out what the problem was. I'd omitted on onChange event in list A for list C. It now works as designed
May 21 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: David | last post by:
Hi, This is the first time I use SOAP. Dont really know the exact picture yet. Hope you can shed some lights on me. May I know where should I start troubleshooting if I get the followin error...
1
by: Robert A Riedel | last post by:
I am completely baffled when the following managed exception is thrown: "Object reference not set to an instance of an object" from a nested subroutine when referencing a variable allocated on the...
3
by: Lori McDonald | last post by:
I am logging errors in my web application in a database for troubleshooting (and emailing them to myself) and I am getting this error I cannot understand I have a click event that is generating an...
4
by: MattB | last post by:
I'm just trying to do some simple javascript in a form to convert Lbs in one textbox to kg in another. I'm doing the following inside a If Not IsPostBack block: Dim strLbs2kg As String...
2
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking....
2
by: siewong | last post by:
Existing Access Database Troubleshooting I am new to access database and inherited an access application and all users who were previously able to use this access file simulataneously are now...
1
by: jobs | last post by:
Re: Troubleshooting Timeout expired. All pooled connections were in use and max pool size was reached. New webservers. win2003. IIS6. asp.net 2.0/ sql server 2005 and Oracle 9i through a 64 bit...
10
by: Daniel Peterson | last post by:
I'm responsible for a pair of IIS 6 webservers that run our production ASP.Net application. We push code on a monthly basis, and about two weeks after our October code push, we started to run into...
2
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set...
4
omerbutt
by: omerbutt | last post by:
hi everyone can any one guide me if there is any add-on related to troubleshooting javascript errors in IE6 regards, Omer Aslam
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.