I have the following code:
jsonOptions = [{"description": "Carro 1", "product": "4"},
{"description": "Carro 2", "product": "5"},
{"description": "Carro 3", "product": "6"},
{"description": "Carro 4", "product": "7"},
{"description": "Carro 5", "product": "8"}
];
I use it to fill a <select>
using the value of description
to build <option>
jsonOptions.forEach(function(item) {
var option = document.createElement('option');
option.text = item.description;
dataList.appendChild(option);
});
What I am not able to do is: When I select one of the options, it sends the value that was captured, so in case, if I select the first value it returns me the text "Car 1". Show!
What I needed was type, if the value selected was Car 1, it picks up the second value and tosses in a variable. It would be like:
Send car 1 to a variable Then fetch the second value "4" and play to another variable