Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > AJAX

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 10-15-2009, 11:01 PM
CssQueen CssQueen is offline
Registered User
 
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 08:08 AM. Reason: Added Code Tags
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Please with sorting XML data in datagrid Cab_0001 ASP.NET 7 01-18-2007 09:33 PM
Qustion about get and set xml data (string) to DataSet Peter XML 0 05-01-2003 06:42 PM
Try XML Junction Tim xml.announcements 0 10-11-2001 05:00 PM
Data Junction Announces XML Junction 7.51 Tim Frost xml.announcements 0 04-02-2001 11:53 AM
XML Security HSIN NING Web 0 08-21-2000 01:21 AM


All times are GMT -4. The time now is 12:21 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.