I am new to json and know nothing about it, but, seeing the power it gives, I plan to switch to it for better performance. In my web application, I have three different drop-down lists: say, sedans, a sunroof and an SUV.
I want, whenever a user clicks on any of them, say, a stroke, the "name" of all strokes in the json file is loaded in the drop-down list. When the user clicks on any name of the hatch, the corresponding price and the car manufacturer are displayed in the id="show" content on the html page.
What should be the jquery fragment that I need to call to do this / how I will continue. I am new to jquery and don't know anything about json, so a little help / guide would be appreciated.
Thanks in advance, please find the contents of the files for a better idea.
Content of my html file (I use twitter bootstrap)
<div id="abc"> <div class="btn-group"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown">Hatch</button><ul class="dropdown-menu"> <li><a href="#">Hatch names here one below the other</a></li> <li><a href="#">Next Hatch name here</a></li> <li><a href="#">Next Hatch name here</a></li> </ul> </div> <div class="btn-group"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown">Sedan</button><ul class="dropdown-menu"> <li><a href="#">Sedan names here one below the other</a></li> <li><a href="#">Next Sedan name here</a></li> <li><a href="#">Next Sedan name here</a></li> </ul> </div> <div class="btn-group"><button type="button" class="btn dropdown-toggle" data-toggle="dropdown">SUV</button><ul class="dropdown-menu"> <li><a href="#">SUV names here one below the other</a></li> <li><a href="#">Next SUV name here</a></li> <li><a href="#">Next SUV name here</a></li> </ul> </div> </div> <div id="show"></div>
The contents of my json file (intended for local storage in the website root folder)
{ "Hatch": [ { "name": "Fiesta", "price": "1223", "maker": "Ford" }, { "name": "Polo", "price": "3453", "maker": "VW" } ], "Sedan": [ { "name": "Mustang", "price": "1223", "maker": "Ford" }, { "name": "Jetta", "price": "3453", "maker": "VW" } ], "SUV": [ { "name": "Santa Fe", "price": "1223", "maker": "Hyundai" }, { "name": "Evoque", "price": "3453", "maker": "Land Rover" } ] }
json javascript jquery html twitter-bootstrap
Learning always
source share