473,398 Members | 2,120 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,398 software developers and data experts.

Fill a double combo

3
Hi guys I have a little problem solving a query for an xml file, i have to put in a drop down list all the "Provincias" from a selected "Departamento", my xml is like this
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <departamentos>
  3.   <departamento>
  4.     <id>1</id>
  5.     <nombre>Lima</nombre>
  6.       <provincias>
  7.           <provincia>
  8.               <id>1</id>
  9.               <nombre>Lima</nombre>
  10.           </provincia>
  11.           <provincia>
  12.               <id>2</id>
  13.               <nombre>Barranca</nombre>
  14.           </provincia>
  15.       </provincias>
  16.   </departamento>
  17.   <departamento>
  18.     <id>2</id>
  19.     <nombre>La Libertad</nombre>
  20.       <provincias>
  21.           <provincia>
  22.               <id>1</id>
  23.               <nombre>Trujillo</nombre>
  24.           </provincia>
  25.           <provincia>
  26.               <id>2</id>
  27.               <nombre>Chepen</nombre>
  28.           </provincia>
  29.       </provincias>
  30.   </departamento>
  31. </departamentos>
  32.  
and my code in javascript is like this:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head runat="server">
  6.     <title>Página sin título</title>
  7.  
  8.     <script language="javascript" type="text/javascript">
  9.     var http_request = false;
  10.     function makeRequest(url, parameters, functionName){
  11.         if(window.XMLHttpRequest){
  12.             http_request = new XMLHttpRequest();
  13.             if(http_request.overrideMimeType){
  14.                 http_request.overrideMimeType('text/xml');
  15.             }
  16.         }
  17.         else if(window.ActiveXObject){
  18.             try{
  19.                 http_request = new ActiveXObject("Msxml2.XMLHTTP");
  20.             }
  21.             catch (e){
  22.                 try{
  23.                     http_request = new ActiveXObject("Microsoft.XMLHTTP");
  24.                 }
  25.                 catch (e){}
  26.             }
  27.         }
  28.         if(!http_request){
  29.             alert('No se pudo cargar correctamente el objeto XMLHTTPRequest');
  30.             return false;
  31.         }
  32.  
  33.         var cadena = "http_request.onreadystatechange = " + functionName;
  34.         eval(cadena);
  35.         http_request.open('GET', url + parameters, true);
  36.         http_request.send(null);
  37.     }    
  38.  
  39.     function do_xml(functionName){
  40.         makeRequest('data.xml', '', functionName);
  41.     }
  42.     function SetDepartamentos(){
  43.         if(http_request.readyState == 4){
  44.             if(http_request.status == 200){
  45.                 var xmldoc = http_request.responseXML;
  46.                 var depas = xmldoc.getElementsByTagName('departamento');
  47.                 var ddl = document.getElementById('DDLdepartamentos');
  48.                 for(var i = 0;i<depas.length;i++){
  49.                     ddl.options[ddl.options.length]=new Option(depas[i].getElementsByTagName("nombre")[0].firstChild.nodeValue, depas[i].getElementsByTagName("id")[0].firstChild.nodeValue);
  50.                    }
  51.             }
  52.             else{
  53.                 alert('Hubo un problema al realizar la peticion');
  54.             }           
  55.         }
  56.     }
  57.     function SetProvincias(){
  58.     if(http_request.readyState == 4){
  59.             if(http_request.status == 200){
  60.                 var xmldoc = http_request.responseXML;
  61.                 var provi = xmldoc.getElementsByTagName('provincia');
  62.                 var depa = document.getElementById('DDLdepartamentos').nodeValue;
  63.                 var ddl = document.getElementById('DDLprovincias');
  64.                 for(var i = 0;i<provi.length;i++){
  65.                     dll.options[dll.options.length]=new Option(depa.provi[i].getElementsByTagName("nombre")[0].firstChild.nodevalue, depa.provi[i].getElementsByTagName("id")[0].firstChild.nodeValue);
  66.                 }
  67.             }
  68.             else{
  69.                 alert('Hubo un problema al realizar la peticion');
  70.             }           
  71.         }
  72.     }
  73.     </script>
  74.  
  75. </head>
  76. <body onload="do_xml(SetDepartamentos)">
  77.     <form id="form1" runat="server" >
  78.         Departamentos<br />
  79.         <select id="DDLdepartamentos" name="DDLdepartamentos" onchange="do_xml(SetProvincias)">
  80.         </select><br />
  81.         Provincias<br />
  82.         <select id="DDLprovincias" name="DDLprovincias">
  83.         </select>
  84.     </form>
  85. </body>
  86. </html>
  87.  
May 6 '07 #1
5 4813
acoder
16,027 Expert Mod 8TB
Welcome to TSDN.

So what's the problem?
May 7 '07 #2
Italus
3
Thx for the wellcome
My problem is that i cant fill the second combo box
May 11 '07 #3
iam_clint
1,208 Expert 1GB
whats the error?
May 11 '07 #4
pbmods
5,821 Expert 4TB
Is it bigger than a breadbox?

Sorry; I thought we were playing 20 questions :P
May 12 '07 #5
iam_clint
1,208 Expert 1GB
Is it bigger than a breadbox?

Sorry; I thought we were playing 20 questions :P
what?

LOL just kidding lets stay on topic guys lets get this one answered!
May 12 '07 #6

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

Similar topics

0
by: Jim | last post by:
Hi, there, I am a beginner on Access. I have been taking so long time to try to figure out his, but so far, no clues. I want to select 2 combo boxes and Access will automatically fill in...
4
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
2
by: Joanne Lewis | last post by:
I am having a great deal of difficulty with a form. Basically, I would like to enter an account # and have the account #, patient first name, and patient last name automatically fill. The form...
1
by: Tom G | last post by:
Hello, I need some advice on which way to resolve the following. On a form, the user will make a selection from a combo box, after the selection several different fields need to be updated on...
2
by: Uninvisible | last post by:
I have put together a db for a law firm to keep track of counterfeit activities. There are four parent tables: tblContact tblTransaction tblAction tblFile I have created a form,...
3
by: Wajih-ur-Rehman | last post by:
I am developing a C# app. I want to do something when someone double clicks on a combo box. But this event never fires. Any suggestions? Thanx!
2
by: Jeremy Dillinger | last post by:
I have a program setup to pull data from a database. My database table has things such as (category, Item, price, etc.) In my program I want to have multiple list boxes that will have a pull down...
18
by: Vayse | last post by:
Has anyone an example of filling a combo box with a data reader? Thanks Vayse
0
by: CanFlightSim | last post by:
I use combo boxes and a great little piece of code to fill a form with a record set. For example I want to search by Lastname and fill the form or by company and fill the form, I will start typing...
5
by: Tark Siala | last post by:
hi dear i'm programmer with VB6, but now i starting with C#. first problem is coming when i need fill "ComboBox Control", as you know when i fill combobox in VB6 by this code: comboX.AddItem...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.