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

181
Visualizações
Drop down box to include a link using windows.open

Need some help with this. I have a drop down list which is part of form but i need only one select to be a link using something that will active once clicked. Not sure is window.open is the correct thing to use.

Here is the code i'm using but at present all select are links and i only need 'other' to be it.

        <select name="model" onchange="window.open(this.value, '_blank')">
        <option value="" selected>Please select</option>
        <option value="A">Apple</option>
        <option value="B">Boom</option>
        <option value="C">chin</option>
        <option value="http://to be a link ">Other..</option>
        </select>

Is this possible to do?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can try something like this. If the value is an URL you can open a new window.

<select name="model" onchange="this.value.includes('http') && window.open(this.value, '_blank')">
  <option value="" selected>Please select</option>
  <option value="A">Apple</option>
  <option value="B">Boom</option>
  <option value="C">chin</option>
  <option value="http://to be a link ">Other..</option>
</select>
about 4 years ago · Santiago Trujillo Relatório

0

You can try this

I do not recommend using inline event handlers

NOTE: The script will not actually run here from a stacksnippet due to sandboxing

document.querySelector("[name=model]").addEventListener("change", function() {
  const val = this.value;
  if (val.startsWith("http")) {
    console.log("This will open",val)
    window.open(val, "_blank")
  }  
})
<select name="model">
  <option value="" selected>Please select</option>
  <option value="A">Apple</option>
  <option value="B">Boom</option>
  <option value="C">chin</option>
  <option value="https://to be a link ">Other..</option>
</select>

about 4 years ago · Santiago Trujillo 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