|
|
@@ -114,13 +114,14 @@ |
|
|
|
|
|
|
|
<div class="inline field"> |
|
|
|
<label>数据集</label> |
|
|
|
<input type="text" list="cloudbrain_dataset" placeholder="选择数据集" name="attachment" autofocus maxlength="36"> |
|
|
|
<input type="text" list="cloudbrain_dataset" placeholder="选择数据集" name="" id="answerInput" autofocus maxlength="36"> |
|
|
|
<datalist id="cloudbrain_dataset" class="ui search" style='width:385px' name="attachment"> |
|
|
|
{{range .attachments}} |
|
|
|
<option name="attachment" value="{{.UUID}}">{{.Attachment.Name}}</option> |
|
|
|
<option name="attachment" data-value="{{.UUID}}">{{.Attachment.Name}}</option> |
|
|
|
|
|
|
|
{{end}} |
|
|
|
</datalist> |
|
|
|
<input type="hidden" name="attachment" id="answerInput-hidden"> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="inline required field"> |
|
|
@@ -187,4 +188,23 @@ |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
document.querySelector('input[list]').addEventListener('input',function(e){ |
|
|
|
var input = e.target, |
|
|
|
list = input.getAttribute('list'), |
|
|
|
options = document.querySelectorAll('#'+list+' option'), |
|
|
|
hiddenInput = document.getElementById(input.getAttribute('id')+'-hidden'), |
|
|
|
inputValue = input.value; |
|
|
|
hiddenInput.value = inputValue; |
|
|
|
for (let i=0;i<options.length;i++){ |
|
|
|
var option = options[i] |
|
|
|
if(option.innerText===inputValue){ |
|
|
|
|
|
|
|
hiddenInput.value = option.getAttribute('data-value'); |
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
</script> |