web: improve part update reselection
This commit is contained in:
parent
57fa8369f3
commit
74262c6381
|
@ -16,7 +16,7 @@
|
|||
<td class="left">
|
||||
<div class="resize">
|
||||
<input class="fill" type="text" id="terms" name="terms" placeholder="search terms (space seperated, anded)" oninput="search()"><br>
|
||||
<select id="results" size="20" onchange="select()"></select>
|
||||
<select id="results" size="20" onchange="select_part()"></select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="right">
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue