web: improve part update reselection
This commit is contained in:
parent
57fa8369f3
commit
74262c6381
|
@ -16,7 +16,7 @@
|
||||||
<td class="left">
|
<td class="left">
|
||||||
<div class="resize">
|
<div class="resize">
|
||||||
<input class="fill" type="text" id="terms" name="terms" placeholder="search terms (space seperated, anded)" oninput="search()"><br>
|
<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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="right">
|
<td class="right">
|
||||||
|
|
|
@ -34,14 +34,23 @@ function search()
|
||||||
|
|
||||||
function results()
|
function results()
|
||||||
{
|
{
|
||||||
const select = document.getElementById('results');
|
const results = document.getElementById('results');
|
||||||
select.innerHTML = null;
|
let part_id = -1;
|
||||||
|
if (results.selectedIndex >= 0) {
|
||||||
|
part_id = parseInt(results.options[results.selectedIndex].value);
|
||||||
|
}
|
||||||
|
results.innerHTML = null;
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.setAttribute('value', part.id);
|
option.setAttribute('value', part.id);
|
||||||
option.innerHTML = part.name + " (" + part.description + ")";
|
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()
|
function clear()
|
||||||
|
@ -71,7 +80,7 @@ function clear()
|
||||||
attachments.innerHTML = null;
|
attachments.innerHTML = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select()
|
function select_part()
|
||||||
{
|
{
|
||||||
const results = document.getElementById('results');
|
const results = document.getElementById('results');
|
||||||
if (results.selectedIndex >= 0) {
|
if (results.selectedIndex >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue