Jump to content

Search Json with Javascript


mattinahat

Recommended Posts

Hey Everybody, I was hoping someone could help me out as I'm fairly new to Json and javascript in general. I've combed through all the tutorials and sample scripts I could find, but alas! I seem to always stumble to a dead end.

 

Onto my question:

I'm trying to create a javascript enabled searchbar that can display data based on a multidimensional json array.

 

Essentially, I have this view that goes like:

First  | Last  | State

-----------------------

John | Doe    | MA

Alex  | Baker | OH

Jeff  | Ree    | MN

 

and I need to search "john" and then throw "doe" in the same search box.

Is this even possible? Can someone help me out/point me in the right direction?

 

Thanks so much!!

-Matt

Link to comment
https://forums.phpfreaks.com/topic/209151-search-json-with-javascript/
Share on other sites

That would probably be helpful  :)

 

saveJson({
  "groups": [
    {
      "group_id": "0",
      "group_name": "Academic/Admin",
      "group_color": "00ff00"
    },
    {
      "group_id": "4",
      "group_name": "Restaurants",
      "group_color": "0000ff"
    },
    {
      "group_id": "2",
      "group_name": "Residential",
      "group_color": "ff0000"
    },
    {
      "group_id": "6",
      "group_name": "Parking Lots",
      "group_color": "00ffff"
    },
    {
      "group_id": "3",
      "group_name": "Commons",
      "group_color": "ff8000"
    },
    {
      "group_id": "5",
      "group_name": "Other",
      "group_color": "ff00ff"
    }  ]
,
  "subgroups": [
    {
      "subgroup_id": "0",
      "group_id": "2",
      "subgroup_name": "NS",
      "lat": "",
      "lon": ""
    },
    {
      "subgroup_id": "1",
      "group_id": "5",
      "subgroup_name": "sd",
      "lat": "",
      "lon": ""
    },
    {
      "subgroup_id": "2",
      "group_id": "6",
      "subgroup_name": "fef",
      "lat": "",
      "lon": ""
    }  ]
});

 

and so on, this is just a snippet; there are more text based items further along, and I need to search each part of group and subgroup in one box.

 

Thanks for all your help in advanced!

-Matt

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.