473,320 Members | 1,879 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,320 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 4811
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.