Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
How to translate completion suggestions by clicking the word on suggestion bar?

I can only use HTML, CSS, and Javascript for this project. The app is a translator. I did most of it, but I have a problem with translating the word which I select in the suggestions (I did create suggestion thing on javascript), it translates the text when I put it on my own, but idk how to do it by selecting it on the suggestion part, any help would be appreciated. HTML code is below.

function checkfortranslate(){
    var input = document.getElementById("input").value;
    var output = document.getElementById("output");
    input = input.toLowerCase();

    if(input=="able"){
        output.innerHTML = "привет";
    }
    else if(input=="about"){
        output.innerHTML = "привет";
    }
    else if(input=="allow"){
        output.innerHTML = "привет";
    }
    else if(input=="above"){
        output.innerHTML = "благодарю вас";
    }
    else if(input=="abroad"){
        output.innerHTML = "привет";
    }
    else if(input=="accident"){
        output.innerHTML = "привет";
    }
}
<h2>SIMPLE ENGLISH TRANSLATOR</h2>
<form autocomplete="off">
  <div>
    <input id="input" type="text" placeholder="Write text to translate" onkeyup="checkfortranslate()">
    <ul class="list"></ul>
    <div id="output" style="display: inline;">[Translation]</div>
  </div>
</form>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use html datalist element.

<datalist id="input" type="text" placeholder="Write text to translate" onkeyup="checkfortranslate()">
     <option value="able">
     ...
     <option value="accident">
    </datalist>

Edit:

<input id="input" type="text" placeholder="Write text to translate" onkeyup="checkfortranslate()" list="list">
 <datalist id="list">
     <option value="able">
     ...
     <option value="accident">
    </datalist>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda