[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1174
  • Last Modified:

Javascript change dropdown value to attribute of responseXML AJAX

I need to change the value of a dropdown to the value that comes from an AJAX called PHP script.

I try this two ways and both ways work in FF but not IE:


xmlDoc = xmlHttp.responseXML;
	
	alert(xmlHttp.responseText);
	
	var line = xmlDoc.getElementsByTagName("line")[0];
 
	//document.getElementById('o_contact_type1').value = line.attributes['type'].value;
	
	var type = line.attributes['type'];
	var o_contact_type1 = document.getElementById('o_contact_type1');
	o_contact_type1.options[o_contact_type1.options.length] = new Option(type.text,type.value);

Open in new window

0
ravinesolutions
Asked:
ravinesolutions
1 Solution
 
BenMorelCommented:
Hi, try this :

var type = line.getAttribute('type');

Regards,
Ben
0
 
john4823Commented:
Cannot alert the right value - tried your idea also. This is just a test run.

var title = line.attributes[1].nodeValue;
      xmlHttp = new XMLHttpRequest();
      xmlHttp.open("GET", "secured/get_ids.php?title=" + title, false);
      xmlHttp.send(null);      
      var xmlDoc2 = xmlHttp.responseXML;
      var element2 = xmlDoc2.getElementsByTagName('doc2').item(0);   // Read the first element
      var line2 = element2.getElementsByTagName('line2').item(0);
      alert(line2.attributes[0].nodeValue);

Please suggest why this throws up an error in IE7.
Cheers
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now