Jump to content

Accessing a dropdown by id, named by xml returned


Greywacke

Recommended Posts

hi there,please have a look at TruckCapXchange.com. this page is done in html 4.0, annd is not my work - but why would the id="Makes" dropdown not be referenced by the xml returned? i have previewed the xml returned and it should return the object - but does not. somebody please help! the following is the script that adds the options:

function addoption(arr) {	for (var i = 0; i < arr.length; i++) {		var opt = document.createElement('option');		opt.text = arr[i][1];							// attribute value		opt.value = arr[i][1];							// attribute parent / value		alert(arr[i][0]);		var sel = document.getElementById(arr[i][0]);	//attribute key		try {			sel.add(opt, null);							// standards compliant; doesn't work in IE		}		catch(ex) {			sel.add(opt);								// IE only		}	}}

the xml is being read with the following script:

function alertContents(http_request) {	if (http_request.readyState == 4) {																		// filter state changed		var success = false;		if (http_request.status == 200) {																	// filter errors			var xmldoc = http_request.responseXML;															// get response			//alert(http_request.responseText);			var arr = new Array();			var i = 0;			var rows = xmldoc.getElementsByTagName("attrib");			for (var r = 0; r < rows.length; r++) {				if (rows[r].attributes) {					arr[i] = new Array();					arr[0] = rows[r].attributes.getNamedItem("name").nodeValue;					arr[1] = rows[r].attributes.getNamedItem("value").nodeValue;				}				i++;			}			if (arr) addoption(arr);			// mysql queries / failures			if (xmldoc.getElementsByTagName("sql")[0]) {				if (xmldoc.getElementsByTagName("sql")[0].firstChild) {					var sql = xmldoc.getElementsByTagName("sql")[0].firstChild.data;					if (sql != undefined) {							alert(sql);					}				}			}			success = true;		} else {			success = false;			alert('HTTP' + http_request.status + ': There was a problem with the request.');		}		ajaxloading--;		if (ajaxloading <= 0) document.getElementById("ajaxbg").style.visibility = "hidden";		return success;	}}

somebody please help!!! :)

Link to comment
Share on other sites

ahhhh!!! *kicks my own ######* :) i found i had missed setting the array sent to the addoptions function decently.it was supposed to be arr[0] and arr[1] not arr[0] and arr[1] :)Pierre.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...