-1
Good afternoon, I’m new in development and I’m trying to create a form that collects certain information and generates a file .xls. to avoid fill errors entered select with all possible options but I needed to optimize the search and searching saw the possibility of use jquerry that allowed typing and easy searching but when using the script my form does not return the value selected in select.
html exeplo - this is in my index.html:
<select id="fornecedor" class="form-control" placeholder="Selecione o fornecedor"></select>
Script I use to allow searching for values within select
<script>$('#fornecedor').editableSelect();</script>
example of how I am filling select - combo.js:
var comboForn = document.getElementById("fornecedor");
var opt0fn = document.createElement("option"); opt0fn.value = "0"; opt0fn.text = "Selecione o fornecedor",comboForn.add(opt0fn, comboForn.options[0]);
var opt1fn = document.createElement("option");opt1fn.value = "0";opt1fn.text = "0 - INDEFINIDO",comboForn.add(opt1fn, comboForn.options[1]);
var opt2fn = document.createElement("option");opt2fn.value = "100034";opt2fn.text = "100034 - LOJAS AMERICANAS S.A.",comboForn.add(opt2fn, comboForn.options[2]);
form - book-form.js where I mount my file to later generate . xls
const bookForm = (function($){
var BOOK_SOLIC = $('#solicitante');
var BOOK_FIL = $('#filial');
var BOOK_TIP = $("#tipo");
var BOOK_PLANO = $("#plano");
var BOOK_CENT = $("#centro");
var BOOK_FOR = $("#fornecedor");
var BOOK_VLRT = $("#valor_total");
var BOOK_VLRP = $("#valor_parcela");
var BOOK_QT = $("#quantidade")
var BOOK_DESC = $("#descricao");
var BOOK_APR = $("#aprovacao");
const BOOK_UPDATE_BUTTON = $("#updateButton");
function clear() {
setData();
BOOK_SOLIC.focus();
}
function hasErrors() {
return BOOK_SOLIC.val() === null || BOOK_SOLIC.val() === '';
}
function getData() {
return {
solicitante: BOOK_SOLIC.val(),
filial: BOOK_FIL.val(),
tipo: BOOK_TIP.val(),
plano: BOOK_PLANO.val(),
centro: BOOK_CENT.val(),
fornecedor: BOOK_FOR.val(),
valor_total: BOOK_VLRT.val(),
valor_parcela: BOOK_VLRP.val(),
quantidade: BOOK_QT.val(),
descricao: BOOK_DESC.val(),
aprovacao: BOOK_APR.val(),
};
}
function setData(solicitante='', option='', tipo='', plano='', centro='', fornecedor='', valor_total='', valor_parcela='', quantidade='', descricao='', aprovacao='') {
BOOK_SOLIC.val(solicitante);
BOOK_FIL.val(filial);
BOOK_TIP.val(tipo);
BOOK_PLANO.val(plano);
BOOK_CENT.val(centro);
BOOK_FOR.val(fornecedor);
BOOK_VLRT.val(valor_total);
BOOK_VLRP.val(valor_parcela);
BOOK_QT.val(quantidade);
BOOK_DESC.val(descricao);
BOOK_APR.val(aprovacao);
}
function setSubmitButtonText(str) {
BOOK_UPDATE_BUTTON.text(str);
}
function getSubmitButtonText() {
return BOOK_UPDATE_BUTTON.text();
}
return {
clear: clear,
hasErrors: hasErrors,
getData: getData,
setData: setData,
setSubmitButtonText: setSubmitButtonText,
getSubmitButtonText: getSubmitButtonText,
};
})(jQuery);
sorry if you don’t have the question standard and thanks for the help. abs.
When trying this method did not bring the selected value to the table, but it was no mistake when I try to insert the value as in the others I tried, I believe that there is only a small thing missing in the code that I could not identify
– Gunther Sousa Freire
Improve your question. Here’s how to do it. https://answall.com/conduct
– Ernesto Casanova