-1
Hello guys I’m a beginner in the area and I need to make a textarea or textbox dependent on a select (Reason field) that is every time you select an iten from the list it fills the textarea or textbox field ( Action field) with the dependent answer ( I’m using javascrip and html) loading the data from a spreadsheet Sheets ( large list) for dependency I did in list form as below and it makes the dependency but I do not want the Acao field in list but textbox but when I switch to textbox it does not make the dependency with the Reason field. . can anyone guide me (help) ? Thank you
Html: Document.getElementById("Reason"). addeventlistener("input", List);
function ListaAcao(){
var comboAcao = document.getElementById("Acao");
while (comboAcao.length){
comboAcao.remove(0);
}
var ListaAcao = document.getElementById("Acao");
var TextoAcao = "Escolha uma Ação"
var NovaOpcaoAcao = document.createElement("option");
var TextoNovaOpcaoAcao = document.createTextNode(TextoAcao);
NovaOpcaoAcao.appendChild(TextoNovaOpcaoAcao);
ListaAcao.insertBefore(NovaOpcaoAcao, ListaAcao.lastChild);
document.getElementById("Acao").options[0].disabled = true;
var Motivo = document.getElementById("Motivo").value;
google.script.run.withSuccessHandler(Carregar).Acao(Motivo);
function Carregar(Acao){
if (Acao != "MOTIVO NÃO ENCONTRADO"){
var ListaAcao = document.getElementById("Acao");
Acao.forEach(function(r){
var TextoAcao = r[0];
var NovaOpcaoAcao = document.createElement("option");
var TextoNovaOpcaoAcao = document.createTextNode(TextoAcao);
NovaOpcaoAcao.appendChild(TextoNovaOpcaoAcao);
ListaAcao.insertBefore(NovaOpcaoAcao, ListaAcao.lastChild);
});
}
}
}
Javascript
Function Acao(Reason) {
var Spreadsheet = Spreadsheetapp.openByUrl(url); var Tab = Spreadsheet.getSheetByName("Lists"); var Localsearch = Guia.getRange(2, 27, 1, Guia.getLastColumn()). getValues()[0];
var Result = Localsearch.Search(Reason);
if (Result != -1){
var Column = Result + 27
Guia.getRange(3, Coluna). Activate(); getCurrentCell(). getNextDataCell(Spreadsheetapp.Direction.DOWN). Ctivate();
var Qtdlinha = Guia.getCurrentCell(). getRow(); var Qtdlinha = Qtdlinha - 2
var Data = getRange(3, Column, Qtdlinha). getValues();
Return Dados;
}Else{
Return 'REASON NOT FOUND'
}
}
Array.prototype.Search = Function(Search){
if (Search == "") Return false;
for ( var Line = 0; Line<this.length; Line ++)
if (this[Line] == Search) Line;
Return - 1
}
Very good worked I used this methodology a little different from what I needed but it worked and thank you
– Mayara Fernandes