I want to use a form above my data table to query a prepopulated JSON file.

I want to use a form above my data table to query a prepopulated JSON file.

hungrymancwopa42hungrymancwopa42 Posts: 6Questions: 3Answers: 0

Hi All -

I am very new to this.

I have two files

mysite/table.html
mysite/data.JSON

table.html is currently loading all values from data.JSON and putting them into a data table.

I have input boxes and drop down menus above the data table that are not currently "connected".

My goal is to be able to choose a value from a dropdown box, click search, and only return values into the table that match in the JSON.

I was looking for examples on datatables.net but I am not exactly sure what this is called. Could someone point me in the right direction?

Thanks so much.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Use the search() method to search the table for the string you want. Or column().search() if that data is in a single column.

    Trigger your search from a change event on the select element.

    Allan

  • hungrymancwopa42hungrymancwopa42 Posts: 6Questions: 3Answers: 0

    Thank you, allan. This worked!!!

    One follow up question will coming in a new post.

    I marked this post as answered/resolved.

    Thanks again.

This discussion has been closed.