You need to log in to create posts and topics.

Javascript JSON Search

<!DOCTYPE html>
<html>
<body>

<h2>Create Object from JSON String</h2>
<p id="demo"></p>

<script>

//this is JSON table converted from Exce or CSV. Headers are NAME, VALUE, COLOR and DATE
table = 
[{"NAME":"Alan","VALUE":12,"COLOR":"blue","DATE":"Sep. 25, 2009"},
{"NAME":"Shan","VALUE":13,"COLOR":"green\tblue","DATE":"Sep. 27, 2009"},
{"NAME":"John","VALUE":45,"COLOR":"orange","DATE":"Sep. 29, 2009"},
{"NAME":"Minna","VALUE":27,"COLOR":"teal","DATE":"Sep. 30, 2009"}];


//alert(restaurants[1].NAME);
var answer;
for(var i = 0; i < table.length; i++)

{
if(table[i].NAME == 'Alan')
{//I am searching for Alan and finding its corresponding color
answer = table[i].DATE;
}
}


document.getElementById("demo").innerHTML = answer;
</script>

</body>
</html>

Check the JSON on https://www.jslint.com/

Covert the excel on: https://shancarter.github.io/mr-data-converter/

While converting select the option JSON properties

Javascript for Permutation

<!DOCTYPE html>
<html>
<body>

<h2>PERMUTATION COMBINATION</h2>

<p id="demo"></p>

<script>
var combination = "AGE,PPT,BONUS,PREMIUM";
var PPT = ["6 Years PPT","8 Years PPT","10 Years PPT","12 Years PPT"];
var Bonus = ["CB","SRIBCB","PPTCB"];
var Premium = ["1 Lakh","2 Lakh","5 Lakh"];

for (var age = 18; age < 55; age++)
{
for(var a = 0; a < PPT.length; a++)
{//alert(PPT[a]);
for(var b = 0; b < Bonus.length; b++)
{ 
for (var c = 0; c < Premium.length; c++)
{ //alert(PPT[a]+"-"+Bonus[b]+"-"+Premium[c]);

combination = combination + "<br>" + age + "Years Age"+","+PPT[a]+","+Bonus[b]+","+Premium[c];
//alert(combination);
}
}
}
}
document.getElementById("demo").innerHTML = combination;

</script>

</body>
</html>
If there’s one place where you can see my regular updates, it’s this one. Welcome to my idea dumping ground. This is my warehouse for all the ideas that I get while I do some other important stuffs. Then I revisit this place at my leisure time to work on those sparks.
Found something useful and want to discuss?
Sure! Feel free to connect.