dropdown menu pulling xml data


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: dropdown menu pulling xml data

  1. #1
    Join Date
    Oct 2009
    Posts
    1

    dropdown menu pulling xml data

    Hello,

    I am trying to populate data from an xml file when a certain catergory from the dropdown menu is selected.

    The dropdown menu is also populated from a xml source different from the one where the data is stored that needs to be pulled.

    so when a category is selected from the dropdown - the selected value will populate the data from the xml source.

    I am having trouble displaying the data when a category is selected from the drop down menu.

    here is the code:

    Code:
    <html>
    <head>
    <title>AJAX</title>
    <link href="layout.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="zxml.js"></script>
    <script type="text/javascript">
    
    function getProduct() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("post","products.xml",true);
    oXmlHttp.onreadystatechange = function () {
    if (oXmlHttp.readyState == 4) {
    if (oXmlHttp.status == 200) {
    
    var product = response.getElementsByTagName('product_line').SelectedIndex;
    
    // not sure where to go from here????
    
    }
    }
    
    }
    }
    
    function popList() {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("get","categories.xml",true);
    oXmlHttp.onreadystatechange = function () {
    if (oXmlHttp.readyState == 4) {
    if (oXmlHttp.status == 200) {
    
    var response = oXmlHttp.responseXML;
    var theIndex = 0;
    var manList = document.getElementById("products");
    
    var o = new Option("Please Select a Category2","what ever");
    manList.options.add(o,theIndex);
    
    var my_names = response.getElementsByTagName('category');
    for(var i=0; i<my_names.length; i++)
    {
    
    ++theIndex;
    var theName = response.getElementsByTagName('category')[i].firstChild.data;
    var productLine = response.getElementsByTagName('category')[i].getAttribute('product_line')
    
    var optionText = productLine + " - " + theName;
    var optionValue = productLine + "|" + theName;
    
    var o = new Option(optionText,optionValue);
    manList.options.add(o,theIndex);
    var Timer = setInterval(theName,productLine);
    
    } 
    
    } else {
    displayCustomerInfo("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
    }
    
    } 
    }
    oXmlHttp.send(null); 
    }
    </script>
    
    </head>
    <body onLoad="popList()">
    Ajax Test Page<br />
    <form>
    <select id="products">
    </select>
    
    <input type="button" value="Show Products" onClick="getProduct()"> 
    </form>
    <div id="body">to be replaced</div>
    </body>
    </html>
    and here is the xml source I would like to pull once a category is selected... the category will be the "sub_group" attribute from this code
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <data>
    <product product_line="Media &amp; USB Keys" sub_group="CD" sku="100CDQ80LS3">
    <brand>Sony</brand>
    <heading>Sony CD-R</heading>
    <description>Designed for optimum performance with multi-speed drives. Compatible with selected CDR-RW drives. 1x--48x write speed. 80 minutes recording time; 700 MB capacity.</description>
    <descriptor>100-pack spindle</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="CD" sku="10CDQ80">
    <brand>Sony</brand>
    <heading>Sony CD-R</heading>
    <description>Designed for optimum performance with multi-speed drives. Compatible with selected CDR-RW drives. 1x--48x write speed. 80 minutes recording time; 700 MB capacity.</description>
    <descriptor>10-pack with slim jewel cases</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="CD" sku="CDQ80SB" >
    <description>Designed for optimum performance with multi-speed drives. Compatible with selected CDR-RW drives. 1x--48x write speed. 80 minutes recording time; 700 MB capacity.</description>
    <descriptor>50-pack spindle</descriptor>
    <image>images/trans.gif</image>
    <brand>Sony</brand>
    <heading>Sony CD-R</heading>
    </product>
    
    <product product_line="Media &amp; USB Keys" sub_group="Midrange Media" sku="1838000">
    <brand>Maxell</brand>
    <heading>Maxell LTO Data Cartridge</heading>
    <description>4.7 GB oOptimized for high capacity and performance with exceptional reliability in either a stand-alone or automated environment. Patented ceramic coated metal particle tape. Ideal for server back-up, restore and archival applications.</description>
    <descriptor>Ultrium 1. 100/200 GB</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="Midrange Media" sku="1838500">
    <brand>Maxell</brand>
    <heading>Maxell LTO Data Cartridge</heading>
    <description>4.7 GB oOptimized for high capacity and performance with exceptional reliability in either a stand-alone or automated environment. Patented ceramic coated metal particle tape. Ideal for server back-up, restore and archival applications.</description>
    <descriptor>Ultrium 2. 200/400 GB</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="Midrange Media" sku="1839000">
    <brand>Maxell</brand>
    <heading>Maxell LTO Data Cartridge</heading>
    <description>4.7 GB oOptimized for high capacity and performance with exceptional reliability in either a stand-alone or automated environment. Patented ceramic coated metal particle tape. Ideal for server back-up, restore and archival applications.</description>
    <descriptor>Ultrium 3. 400/800 GB</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="Midrange Media" sku="183906-0">
    <brand>Maxell</brand>
    <heading>Maxell LTO Data Cartridge</heading>
    <description>4.7 GB oOptimized for high capacity and performance with exceptional reliability in either a stand-alone or automated environment. Patented ceramic coated metal particle tape. Ideal for server back-up, restore and archival applications.</description>
    <descriptor>Ultrium 4. 800 GB/1.6 TB</descriptor>
    <image>images/trans.gif</image>
    </product>
    
    <product product_line="Media &amp; USB Keys" sub_group="DVD" sku="639011">
    <brand>Maxell</brand>
    <heading>Maxell DVD+R</heading>
    <description>4.7 GB of storage capacity or 120 minutes. Up to 16x write speed. Write-once and single-sided.</description>
    <descriptor>25-pack spindle indle</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="DVD" sku="639013">
    <brand>Maxell</brand>
    <heading>Maxell DVD+R</heading>
    <description>4.7 GB of storage capacity or 120 minutes. Up to 16x write speed. Write-once and single-sided.</description>
    <descriptor>50-pack spindle</descriptor>
    <image>images/trans.gif</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="DVD" sku="639016">
    <brand>Maxell</brand>
    <heading>Maxell DVD+R</heading>
    <description>4.7 GB of storage capacity or 120 minutes. Up to 16x write speed. Write-once and single-sided.</description>
    <descriptor>100-pack spindle </descriptor>
    <image>images/trans.gif</image>
    </product>
    
    <product product_line="Media &amp; USB Keys" sub_group="CD" sku="648200">
    <brand>Maxell</brand>
    <heading>Maxell 48x CD-Recordable</heading>
    <description>48x write speed. 80 minutes recording time; 700 MB capacity.</description>
    <descriptor>100-pack spindle</descriptor>
    <image>images/648200.jpg</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="CD" sku="648210">
    <brand>Maxell</brand>
    <heading>Maxell 48x CD-Recordable</heading>
    <description>48x write speed. 80 minutes recording time; 700 MB capacity.</description>
    <descriptor>Slim jewel case. Package of 10</descriptor>
    <image>images/648210.jpg</image>
    </product>
    <product product_line="Media &amp; USB Keys" sub_group="CD" sku="648250">
    <brand>Maxell</brand>
    <heading>Maxell 48x CD-Recordable</heading>
    <description>48x write speed. 80 minutes recording time; 700 MB capacity.</description>
    <descriptor>50-pack spindle</descriptor>
    <image>images/648250.jpg</image>
    </product>
    
    <product product_line="Media &amp; USB Keys" sub_group="Blu Ray" sku="631002">
    <brand>Maxell</brand>
    <heading>Maxell Blu-ray DVD </heading>
    <description>Single-layer disc. 1--2x. 25 GB. </description>
    <descriptor>Rewritable</descriptor>
    <image>images/trans.gif</image>
    </product>
    </data>
    Last edited by Hack; 10-16-2009 at 07:08 AM. Reason: Added Code Tags

Similar Threads

  1. Help Please with sorting XML data in datagrid
    By Cab_0001 in forum ASP.NET
    Replies: 7
    Last Post: 01-18-2007, 08:33 PM
  2. Replies: 0
    Last Post: 05-01-2003, 05:42 PM
  3. Try XML Junction
    By Tim in forum xml.announcements
    Replies: 0
    Last Post: 10-11-2001, 04:00 PM
  4. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 10:53 AM
  5. XML Security
    By HSIN NING in forum Web
    Replies: 0
    Last Post: 08-21-2000, 12:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center