所以我在我的网站主页上有这个搜索框,我希望它作为“从画廊(jason 文件)中按名称搜索汽车”并将汽车显示给用户,现在我不太懂确定如何实现这一目标,对实际代码的任何帮助将不胜感激。
我的杰森文件:
{
"cars" :
[
{
"model": "Mazda Nagare",
"year": "2013",
"country": "Japan",
"plate": "y72-28f-609",
"price": "220,000",
"pic" : "images/MazdaNag.jpg"
},
{
"model": "BMW M135i",
"year": "2011",
"country": "Germany",
"plate": "bmw-016-ur2",
"price": "140,000",
"pic" : "images/BMWM135i.jpg"
},
{
"model": "Mazda 6",
"year": "2007",
"country": "Germany",
"plate": "x57-6u6-fev",
"price": "110,000",
"pic" : "images/Mazda6.jpg"
},
{
"model": "Toyota 9T",
"year": "2013",
"country": "Japan",
"plate": "qwe-rty-013",
"price": "390,000",
"pic" : "images/toyota_9turbo.jpg"
},
{
"model": "Toyota GTS",
"year": "2012",
"country": "Japan",
"plate": "6r2-x0r-65y",
"price": "177,000",
"pic" : "images/ToyotaGts.jpg"
},
{
"model": "Toyota GT-86",
"year": "2013",
"country": "Japan",
"plate": "ca1-pw9-n3x",
"price": "260,000",
"pic" : "images/ToyotaGt86.jpg"
}
]
}
我的搜索框和按钮(打开一个新的空白页面,我为搜索结果创建的):
<div id="searchBox" data-theme="a">
<input type="search" placeholder="Search for a car by name">
</div>
<div class="smallButtonStyle">
<input type="button" value="Search" onClick="location.href='#search'" data-icon="arrow-r" data-transition="slide"/>