Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-23-2009, 08:44 PM   PM User | #1
mikenye
New to the CF scene

 
Join Date: Apr 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mikenye is an unknown quantity at this point
XML Search.....cant loop to get all node values?

Hi all,

Sorry Ive just realized I posted this in the wrong section....Im still new to this but learning fast.

I have a set of code that searches an xml sheet then displays the relevant Airfield searched for in a <span> below this it should display All the relevant airport plates (small maps) and be linked to their correct PDF.

The above works however I can only get it to display one plate in the span, ive tried a few different loops to try and get it to retrieve all the node information but am now chasing my tail can somone please have a look at the code below and let me know where im going wrong and suggest a solution?

Thanks
Mike




Code:
function searchXml(){
	
	getText=document.getElementById("searchText").value.toUpperCase();
	var countrys = xmlPdfDoc.getElementsByTagName('Country');
	
	
	//alert("Looking for "+getText);
	//the node numbers are different for Moz and IE
	if (window.ActiveXObject) {
		nodeNum=0;
	}
	else{
		nodeNum=1;
	}
	
	
	
	
	for(var i=0; i<countrys.length; i++){
		
		
		var airfields = countrys[i].getElementsByTagName("AirField");
		
		
		for(var airfieldNo=0; airfieldNo<airfields.length; airfieldNo++){
			
				
				
				optIcao=airfields[airfieldNo].getElementsByTagName("name")[0].childNodes[0].nodeValue;
				optIcao=optIcao.substring(0,4);
				
				optTexts=airfields[airfieldNo].getElementsByTagName("name")[0].childNodes[0].nodeValue;
				
				
				//This line brings in the a chart name.
				optRes=airfields[airfieldNo].getElementsByTagName("Plate")[j].childNodes[nodeNum].childNodes[0].nodeValue;
				
				//This line brings in the PDF Name relevant to the chart
				optResPlate=""+airfields[airfieldNo].getElementsByTagName("Plate")[j].childNodes[nodeNum+nodeNum+1].childNodes[0].nodeValue+".pdf";
				
				
				if(optTexts.search(getText)>=0){
					//alert("found match "+optTexts+", in country #"+i+"airfield #"+optValue);
					//fileName="+optText+";
					
					Results(optTexts+"" ) ;
					
				}
				
				
				
		}
		
	}



}

// Displays the Search results on screen.

function Results(strDisplay){
	var cartNum=parseInt(document.getElementById("cartNum").value);
	var cartLine="<span  id='cartWrapper"+cartNum+"' class='cartLine'  >";
	cartLine+="<a >"+strDisplay+"</a> ";
	cartLine+="";
	cartLine+="<input type='hidden'  value='enabled' id='cartValid"+cartNum+"'/><br><span><img src='images/pdf.PNG' >&nbsp;<a href='./taps/"+optResPlate+"' target='_blank'>"+optRes+"</a><br>&nbsp;<br></span>";
	cartLine+="<br></span>";
	
	//alert(cartLine);
	document.getElementById("cart").innerHTML+=cartLine;
	document.getElementById("cartNum").value=parseInt(cartNum+1);
}
mikenye is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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


All times are GMT +1. The time now is 08:52 AM.


Advertisement
Log in to turn off these ads.