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

201
Visualizações
Pass dropdown value to onclick method

I have a dropdown and link. I'm trying to pass selected dropdown value to onclick.

    <div>
        <select class="browser-default custom-select" id="venflows">
            <option value="marcus">marcus</option>
            <option value="bruno">bruno</option>
            <option value="jadon">jadon</option>
            {% endfor %}
        </select>
    </div>



        <div>
            <a onclick="window.location.href = 'download/dropdown_selected_value_here'"></a>
        </div>

Here i'm trying to pass selected dropdown value to click. Ex: if marcus is selected when onclick it should be like this

        <div>
            <a onclick="window.location.href = 'download/marcus'"></a>
        </div>

Ex: if bruno is selected when onclick it should be like this

        <div>
            <a onclick="window.location.href = 'download/bruno '"></a>
        </div>
about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

To answer your question as posed

<a onclick="window.location.href = 'download/'+document.getElementById('venflows').value"></a>

But I recommend an eventListener

document.getElementById("link").addEventListener("click", function() {
  const url = `download/${document.getElementById("venflows").value}`
  console.log(url); // for testing
  this.href = url;
})
<div>
  <select class="browser-default custom-select" id="venflows">
    <option value="marcus">marcus</option>
    <option value="bruno">bruno</option>
    <option value="jadon">jadon</option>
  </select>
</div>
<div>
  <a href="" id="link">GO</a>
</div>

about 4 years ago · Santiago Gelvez Relatório

0

If you want onclick event then you can try this

       <select class="browser-default custom-select" id="venflows" onclick="customFunction(this)">
            <option value="marcus">marcus</option>
            <option value="bruno">bruno</option>
            <option value="jadon">jadon</option>
            {% endfor %}
        </select>
          
       <div>
            <a onclick="window.location.href = 'download/dropdown_selected_value_here'" id="url_nav"></a>
        </div>
     
        function customFunction(curObj){
            document.getElementById("url_nav").onclick = "window.location.href = 'download/'+curObj.value+"
        }
about 4 years ago · Santiago Gelvez 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