Solved

Issue With the Javascript Arrays

Posted on 2014-11-12
3
121 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
ID: 40438327
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
ID: 40439109
Thank you ..I will give this a try...
0
 

Author Closing Comment

by:Techsavy
ID: 40446019
Thank you. Worked like a charm!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to refer to value 8 48
Hide cell in a table 2 12
tiny glitch in my main slider 3 23
alert(innerHTML); 8 15
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)

770 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