html: < /p>
Код: Выделить всё
Select an option
PVC For Water Mains
PVC For Gravity Sewer
PVC Pressure Rated PIP (IPS)
Ductile Iron Pipe
HDPE Pipe (IPS)
HDPE Pipe (DIPS)
Steel (NPS)
Select an option
Select an option
< /code>
javascript: < /p>
var lookupTable = {
"PVC_Water": {
"4\"": [
"DR-14",
"DR-18",
"DR-21",
"DR-25"
],
"6\"": [
"DR-14",
"DR-18",
"DR-21",
"DR-25"
]
}
};
function secondSelection() {
// Get the selected value from the first drop-down menu
var pipe_mat_value = document.getElementById("pipe_mat_HTML").value;
// Get a reference to the second drop-down menu
var pipe_size = document.getElementById("pipe_size_HTML");
// Remove all existing options from the second drop-down menu
pipe_size.innerHTML = "";
for (const key in lookupTable[pipe_mat_value]) {
pipe_size.add(new Option(key, "pipe_size_value"));
}
}
function thirdSelection() {
// Get the selected value from the first drop-down menu
var pipe_mat_value = document.getElementById("pipe_mat_HTML").value;
// Get a reference to the second drop-down menu
var pipe_size_value = document.getElementById("pipe_size_HTML").value;
var pipe_WT = document.getElementById("pipe_WT_HTML");
console.log(pipe_WT);
console.log(pipe_size_value);
// Remove all existing options from the second drop-down menu
pipe_WT.innerHTML = "";
var WT_array = lookupTable[pipe_mat_value][pipe_size_value];
WT_array.forEach(function(element) {
pipe_WT.add(new Option(element, "pipe_WT_value"));
});
console.log(WT_array);
}
Подробнее здесь: https://stackoverflow.com/questions/755 ... -down-list
Мобильная версия