I am facing an issue with an ajax call in codeigniter where the response always consists of two values: team_id1 and team_id2. Instead of displaying them as separate values like value="1"
and value="2"
, I want to join them together as value="1:2"
. I have attempted using el.join(":");
but it doesn't seem to work. I suspect that appendChild()
is causing the problem. Is there a workaround for this situation? I require the values to be formatted in this way for a dropdown list to function properly. Thank you for your assistance!
function alertContents() {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
var data = JSON.parse(httpRequest.response);
var select = document.getElementById('match');
if(emptySelect(select)){
for (var i = 0; i < data.matchup.length; i++){
var el = document.createElement("option");
el.textContent = data.matchup[i].team_id;
el.value = data.matchup[i].team_id;
select.appendChild(el);
}
}
} else {
alert('There was a problem with the request.');
}
}
}