I am trying get value and the option name from my json data but my value is also coming in option only
here is the demo what ootput i get https://jsfiddle.net/1dekbp9f/
and what i need is
<select id="demo">
<option value="Q1">What is your birth place?</option>
<option value="Q2">What is your first bike?</option>
<option value="Q3">What is your favourite subject?</option>
<option value="Q4">What is your first Mobile?</option>
<option value="Q5">What is your native place?</option>
<option value="Q0">Others</option>
</select>
here is my code what i tried
<select id="demo" ></select>
<script>
var jsonData = {
"cid":"comb_questions",
"mkey":"101_comb_questions",
"pdet":[
{
"key":"N101_comb_questions0",
"val":[
"What is your birth place?",
"What is your first bike?",
"What is your favourite subject?",
"What is your first Mobile?",
"What is your native place?",
"Others"
]
},
{
"key":"N101_comb_questions1",
"val":[
"Q1",
"Q2",
"Q3",
"Q4",
"Q5",
"QO"
]
}
]
};
var text = "";
for (var i=0; i<jsonData.pdet.length; i++) {
var productdetail = jsonData.pdet[i];
for (var j=0; j<productdetail.val.length; j++) {
var productval = productdetail.val[j];
//console.log(productval);
text += "<option value=''>" + productval + "</option>";
}
};
document.getElementById("demo").innerHTML = text;