Skip to content

Instantly share code, notes, and snippets.

@JackOHara
Created November 5, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackOHara/b6cf5376d130f298e24f082a74ad8413 to your computer and use it in GitHub Desktop.
Save JackOHara/b6cf5376d130f298e24f082a74ad8413 to your computer and use it in GitHub Desktop.
<div class="select-box box">
<!-- The option values of the select box are populated from the key names in ethereumfaq.json. When an option is chosen scripts.js uses the key name to retrieve the corrosponding data. This data is then populated as a <ul><li> list in the #faqsection <div> -->
<select id="FAQSelect">
<option value="select">Select..</option>
</select>
</div>
<div id="FAQSection"></div>
//Get FAQ section titles from JSON and add as select options
$.getJSON("json/ethereumfaq.json", function (data) {
for (var k in data) {
$("#FAQSelect").append("<option value='select'>" + k + "</option>");
}
})
//Change which FAQ section from JSON is shown.
$("#FAQSelect").change(function () {
option = $('#FAQSelect option:selected').text()
$("#FAQSection").empty()
if (option != "Select..") {
$.getJSON("json/ethereumfaq.json", function (data) {
for (var k in data[option]) {
$("#FAQSection").append("<hr> <h3>" + k + "</h3><p> " + data[option][k] + "<\p> ");
}
})
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment