Ask your JavaScript questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

add alert based on json lookup JavaScript


The task is to make the <ul> <li>generate a js alert will be generated for each game of the players who played each other last week.

For example: I list the first players as
<li id="I3">Paciorkowski, Lev 2442</li>
and his opponent as:
<li id="I34">MacKenzie, Rando. 2000</li>

But these guys played each other last week, so it should be:
alert ("MacKenzie, Rando. 2000 and Paciorkowski, Lev 2442 played last week!");

1. The localStorage json object of last week's tournament:

[{"SP_1":"Paciorkowski, Lev 2442","SP_2":"MacKenzie, Rando. 2000"},
{"SP_1":"MacKenzie, Rando. 2000","SP_2":"Paciorkowski, Lev 2442"},
{"SP_1":"Slomski, Matt 2000","SP_2":"Stubblebine, Don. 1800"},
{"SP_1":"Stubblebine, Don. 1800","SP_2":"Slomski, Matt 2000"}

I set localStorage with:


function geico() { //builds last week's list

i = 0; archive = [];
while (i < <?php echo $limit; ?>)

{$('ul').each(function() {

A_player = $(this).find('li').eq(i).text();
B_player = $(this).find('li').eq(i+1).text();

archive.push ({SP_1: A_player, SP_2: B_player});
archive.push ({SP_1: B_player, SP_2: A_player});

i++; i++;

localStorage.setItem("names", JSON.stringify(archive)); //store pairings
alert ("This weeks player list is now stored!");
alert (localStorage.getItem("names")); // Works fine !

Answers (1)


Arnav Joy answers:

is it possible you can show me your site?

User180435 comments: