473,387 Members | 3,033 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,387 software developers and data experts.

Problem with javascript cascade comboboxes

Hello:

I am having a problem with to linked comboxes in IE7. Here is my problem that is ONLY ocurring in IE7: I have javascripts functions to populate the second of 2 comboxes given the selected option on the first one; the scripts look to be ok since they work perfectly on firefox 3.08 and also on IE6 and IE8; I have inspected the generated combobox options code using firebug extension on firefox and they are ok; on IE7 the options for the second combo are being populated without errors, but it is crashing after I select an option on the first combobox that only have 1 option asociated in the second combobox and then try to open the second combobox; IE7 crash and is displaying a messages that reads "IE7 has stop responding bla bla....".

Just in case you do not fully understand: my problem only ocurrs if there is only one option on the second combobox, if there are 2+ the problem does not ocurr.

The first combobox has the function setDynaList attached to the OnChange event..

Here are my javascripts functions:

Expand|Select|Wrap|Line Numbers
  1. function setDynaList(cbx1, cbx2, arr, addFirstOption){
  2.     var oList1     = document.getElementById(cbx1);
  3.     var oList2     = document.getElementById(cbx2);
  4.  
  5.     clearDynaList(oList2);
  6.  
  7.     if (oList1.selectedIndex == -1){
  8.         oList1.selectedIndex = 0;
  9.     }
  10.  
  11.     populateDynaList(oList2, oList1[oList1.selectedIndex].value, arr, addFirstOption);
  12.     return true;
  13. }
  14.  
  15. function clearDynaList(oList){
  16.     oList.selectedIndex = -1;
  17.     for (var i = oList.options.length; i >= 0; i--){
  18.         oList.options[i] = null;
  19.     }    
  20.     oList.selectedIndex = -1;
  21. }
  22.  
  23. function populateDynaList(oList, nIndex, aArray, addFirstOption){
  24.     if (addFirstOption == true) {
  25.         var aOption;
  26.         aOption = document.createElement("OPTION");
  27.         aOption.value = '';
  28.         aOption.text = '- select -';     
  29.         oList.options.add(aOption);
  30.     }
  31.  
  32.     for (var i = 0; i < aArray.length; i= i + 3){
  33.         if (aArray[i] == nIndex){
  34.             aOption = document.createElement("OPTION"); 
  35.             aOption.value = aArray[i + 1];
  36.             aOption.text = aArray[i + 2]; 
  37.             oList.options.add(aOption);
  38.         }
  39.     }
  40.  
  41.     if (oList.options.length > 0) {
  42.         oList.selectedIndex = 0;
  43.     } else {
  44.         oList.selectedIndex = -1;
  45.     }
  46. }
  47.  
  48. function setDefaListbyValue(sList, sDefault){
  49.     oList = document.getElementById(sList);
  50.     var found = false;
  51.     for (var i = 0; ((i < oList.options.length) && (!found)) ; i++){
  52.         if (oList.options[i].value == sDefault){
  53.             oList.options[i].setAttribute('selected', 'true');
  54.             oList.options[i].selected = true;
  55.             found = true;
  56.         }
  57.     }    
  58. }
  59.  
  60. function setDefaListbyText(sList, sDefault){
  61.     oList = document.getElementById(sList);
  62.     var found = false;
  63.     for (var i = 0; ((i < oList.options.length) && (!found)) ; i++){
  64.         if (oList.options[i].text == sDefault){
  65.             oList.options[i].setAttribute('selected', 'true');
  66.             oList.options[i].selected = true;
  67.             found = true;
  68.         }
  69.     }    
  70. }
  71.  
  72. function setupDefaList(sList, sDefault, nIndex, aArray, addFirstOption){
  73.     oList = document.getElementById(sList);
  74.     clearDynaList(oList);
  75.     populateDynaList(oList, nIndex, aArray, addFirstOption);
  76.     setDefaListbyText(sList, sDefault);
  77. }
-----------------------------------------------------------
and here is the array that dinamically I and wrting to the page reading from the database:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. //<![CDATA[
  3. var MyItemsArray =  new Array('6','16687','Furniture for care, play and learning', '6','16688','Furnishings for relaxation', '6','16689','Room arrangement', '6','16690','Space for privacy', '6','16691','Child-related display', '6','16692','Space for gross motor', '6','16693','Gross motor equipment', '7','16694','Meals/snacks', '7','16695','Nap/rest', '7','16696','Toileting/diapering', '7','16697','Health practices', '7','16698','Safety practices', '8','16699','Books and pictures', '9','16700','Art', '9','16701','Music / movement', '9','16702','Blocks', '9','16703','Sand / water', '9','16704','Dramatic play', '9','16705','Nature / science', '9','16706','Use of TV, video, and/or computers', '9','16707','Promoting acceptance of diversity', '10','16708','General supervision of children', '11','16709','Schedule', '11','16710','Free play', '11','16711','Group time', '11','16712','Provisions for children with disabilities');
  4. //]]>
  5. </script>
in the array every 3 elements the first element is the parent id(the selected value on the first combobox), the second is the value and the third is the name for the option on the second combobox.

any Idea?
Apr 2 '09 #1
6 2921
acoder
16,027 Expert Mod 8TB
I quickly tested your code with two simple select elements and there were no problems in IE7. Post your HTML code. Do you have any other code, e.g. an onchange in the second combo?
Apr 2 '09 #2
My page is a complex one that uses a database as backend; it is a .net page that uses framework 2.0 and have security , ...., but I can asure you that I have tested this code from many computers and IE7 fails with no exceptions whenever you try to open the second combo and this combo has only one option. I used this code when I was working for a company in Cuba 3 years ago; not being convinced about what was ocurring in my new page I visited one of the pages that uses this code in the cuban website and the error is present there too. It looks like it is a bug in IE7. Here is the URL and the instructions:

the link is: http://www.cubahotelreservation.com/ and there go to a box that you will see at the right of the page; it is the one that reads "Search Cuba Hotels"; the destination combo is the parent and the hotel's combo is the child combobox; select "Centro Havana" destination in the parent (this destination does not have hotels and by this reason the child combo only gets 1 option: - any hotel - ), select another destination like Havana that has a lot of hotels and then go back and select "Centro Havana" again; try to open the child combo to crash your IE7. I think that in my original post I did not specified that the error only ocurrs the second time you open the child combo when it have only one option.
Apr 2 '09 #3
acoder
16,027 Expert Mod 8TB
I tried to crash my IE7 unsuccessfully! For good measure, I even tried it a third time. Perhaps you need to re-install your version of IE7. Is it a stand-alone version or the original?
Apr 2 '09 #4
You are right acoder; it looks like the problem is related to this specific IE7 installation from where I have been testing(I tested from another pc and the error does not ocurr); the one with the problem is a Dell modified version since this computer is a Dell. I would never imagine that a modified version can introduce problems like this one.
May I install the original IE7 version above this one? I am asking because I think it is not possible to remove IE7 from vista and then install it again...and for now I need to have IE7 in this pc for my development testings .
Apr 2 '09 #5
if the solution is to reinstall IE7 on vista; from where can I download the installer? since IE7 comes preinstalled on vista I cannot find the installer for vista anywhere on the MS website...
Apr 3 '09 #6
acoder
16,027 Expert Mod 8TB
You could try resetting IE as described here.
Apr 3 '09 #7

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

Similar topics

2
by: P.B. via SQLMonster.com | last post by:
I cannot execute my sql to create a table with ON DELETE CASCADE option. Here is my sql: CREATE TABLE Employees (Name Text(10) not null, Age number, CONSTRAINT pkEmployees PRIMARY KEY (Name)); ...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
5
by: Mika M | last post by:
Hello! I have Windows Forms application form containing TextBoxes, six ComboBoxes, and DataGrid for details. I have created DataSet with needed tables, and created relations between tables, and...
1
by: Thomas Chille | last post by:
Hello! I have a Problem. A table with a ForeignKeyRef exits. The Name of the field with this FK-Constraint is 'id_employee' because it is referencing the field 'id_employee' in...
1
by: faiyeah | last post by:
Here is my database design: Entity ------ Publisher(, PubName) Author(, AuName) Sale(, Price, UnitOnHand) Book(, Title, BkType, PubCode)
6
by: Jeff North | last post by:
I'm using Microsoft SQL Server Management Studio Express 9.00.2047.00 and expriencing problems with setting referential integrity on a link table. The tables' schema is as follows:...
4
by: Adrock952 | last post by:
I am trying to create my tables where if i delete/update a record from one table, all the other tables are affected by deleting/updating any records that reference the original record. For...
0
by: SF | last post by:
Hi I am new with VB.NET 2005. I am looking for a way to cascade 3 comboxboxes contain provinces, districts and communes. I know that in MS Access but VB.NET i ma stuck after create a form and...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.