|
#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>
Code:
<?xml version="1.0" encoding="iso-8859-1"?> <data> <product product_line="Media & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
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 |