Created
November 5, 2017 14:27
-
-
Save JackOHara/b6cf5376d130f298e24f082a74ad8413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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