Solved

Issue With the Javascript Arrays

Posted on 2014-11-12
3
117 Views
Last Modified: 2014-11-16
Hi,

I have attached the script. What I am trying to do is specified in the comments in the script.

Below are the comments that I specified in the script.

     //check if the pre-built  dashboard items array has a projectdesc that matches the projectName and then build the table row by passing Project Name and projectURL, projectstatuslabel to the getProjectRow function

//Here how do I iterate through dashboard items array to check if there is a matching projectdesc whose string value is equal to ProjectName inside this for loop?

i need to iterate through the dashboard array and find a matching description of the value in the for loop and then get the remaining properties of the object.

Please let me know if this is not clear.
script-2.txt
script-2.txt
0
Comment
Question by:Techsavy
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
vr6r earned 500 total points
Comment Utility
Updated and commented the For loop from your script, give this a try:

for (var i = 0; i < data.d.results.length; i++) {
	var projectName = data.d.results[i].Title;
	var projectURL = data.d.results[i].ProjectURL;

	//set matcheditem var to array of dasboardItems objects filtered by matching projectdesc to projectName
	var matcheditem = $.grep(dashboardItems, function(n){
		return n.projectdesc == projectName;
	});
	
	//check length of resulting matcheditem array from above.
	//if > 0, call getProjectRow using first item in matcheditem array.
	if(matcheditem.length > 0) {
		getProjectRow(projectName, projectURL, matcheditem[0].projectstatuslabel);
	}
	
}

Open in new window


Hope that helps.
0
 

Author Comment

by:Techsavy
Comment Utility
Thank you ..I will give this a try...
0
 

Author Closing Comment

by:Techsavy
Comment Utility
Thank you. Worked like a charm!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now