1
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 the <option>
jsonOptions.forEach(function(item) {
var option = document.createElement('option');
option.text = item.description;
dataList.appendChild(option);
});
What I’m not able to do is: When I select one of the options, it sends the value that was captured, so in this case, if I select the first value it returns the text "Car 1".. Show!
What I needed was type, if the selected value was Car 1, it would take the second value and launch into a variable. It would be like:
Send car 1 to a variable Then fetch the second value "4" and play to another variable
The tags I wrote did not come out. "Fill in a <select>" and "Build the <option>"
– Alexandre Bonadiman Angeli
When you need me, edit the question Alexandre.
– BrTkCa