I want to use an HTML select element to change which thymeleaf fragment is displayed.
the html code:
<label for="algorithm">Algorithm</label>
<select id="algorithm" onchange="getAlgorithmParams(this.value, '#algParams')">
<option value="">Select Algorithm</option>
<option value="ZeroR">ZeroR</option>
<option value="OneR">OneR</option>
<option value="NaiveBayes">Naive Bayes</option>
<option value="IBK">IBK</option>
<option value="J48">J48</option>
</select>
<div id="algParams"></div>
The javascript code:
getAlgorithmParams = function (algorithmName, elementID){
console.log(algorithmName);
console.log(elementID);
document.querySelector(elementID).innerHTML = "<div th:insert='~{/fragments/parameter-fragments :: " + algorithmName + "}'></div>";
}
when the selection is changed i want the div element with the id "algParams" to display a different thymeleaf fragment. When i run it, it shows this in the page elements when i inspect the page.
<div th:insert="~{/fragments/parameter-fragments :: OneR}"></div>
which is the correct notation and should be working.