I am writing a code for a form with a select box in it that has to get populated by the content of a specific html part. I managed to get an id on the specific part (it gets created automatically by the cms) so you can call up the part with javascript.
Problem is i cant figure out how to get the content split by commas like "red, blue, yellow" and split it up into a select box as options.
Here is the part of the javascript code that i have:
function offerte(){
var kleuren = document.getElementById('product_kleuren');
// here has to come a code to populate the select box
}
and the html part:
<div><span class="extra_fields_name">Kleuren</span>:
<span id="product_kleuren" class="extra_fields_value">Naturel, Helder, Zwart</span></div>
<label class="offerte_lbl">Kleur: </label><select id='kleuren' class='offerte_input'></select><br>
I know its not much, I'm still learning javascript but i really cant figure out how to get the content of a specific html part that is split by commas and seperate them into values to populate the selectbox with.