diff --git a/public/index.html b/public/index.html index 79a9b41..d97fc99 100644 --- a/public/index.html +++ b/public/index.html @@ -16,7 +16,7 @@

- +
diff --git a/public/partdb.js b/public/partdb.js index 3cb43e8..f9f4471 100644 --- a/public/partdb.js +++ b/public/partdb.js @@ -34,14 +34,23 @@ function search() function results() { - const select = document.getElementById('results'); - select.innerHTML = null; + const results = document.getElementById('results'); + let part_id = -1; + if (results.selectedIndex >= 0) { + part_id = parseInt(results.options[results.selectedIndex].value); + } + results.innerHTML = null; for (const part of parts) { const option = document.createElement('option'); option.setAttribute('value', part.id); option.innerHTML = part.name + " (" + part.description + ")"; - select.appendChild(option); + if (part_id == part.id) { + console.log(part_id); + option.selected = "selected"; + } + results.appendChild(option); } + select_part(); // in case we reselected } function clear() @@ -71,7 +80,7 @@ function clear() attachments.innerHTML = null; } -function select() +function select_part() { const results = document.getElementById('results'); if (results.selectedIndex >= 0) {