Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    After XML search cant Loop to get all node values?

    Hi all,

    Sorry still new to this but learning fast II 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);
    }

  • #2
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyone? Before I break and hire a contractor?

    cheers
    Mike


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •