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

99
Visualizações
how to redirect user to their selected option page
<main>
    <div class="container">
        <select name="semester" id="select-semester">
            <option value="no-semester">select semester</option>
            <option value="semester 1">semester 1</option>
            <option value="semester 2">semester 2</option>
            <option value="semester 2">semester 3</option>
        </select>
    </div>
</main>

like i have semester1,semester2,semester3 as option so i want that if anyone select semester 1 then he will move to semester 1 page

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

0

I would subscribe to the change event of the select, and then, depending on the selected value, would redirect to the appropriate page

something like this:

<main>
  <div class="container">
    <select name="semester" id="select-semester">
      <option value="">select semester</option>
      <option value="1">semester 1</option>
      <option value="2">semester 2</option>
      <option value="3">semester 3</option>
    </select>
  </div>
</main>


document
  .getElementById('select-semester')
  .addEventListener('change', function (this: HTMLSelectElement) {
    var semesterId = this.value;
    if (semesterId) {
      window.location.href = '/semester-' + semesterId;
    }
  });
about 4 years ago · Juan Pablo Isaza Relatório

0

I made an example here for you! I placed a link below under the select. The value change event replces the href attribute of the tag.

let semester = document.querySelector("#select-semester");
let go = document.querySelector("#go");
semester.addEventListener("change", (e)=> {
    go.href = go.dataset.baselink + semester.value;
    go.innerHTML = "GO to " + semester.value
  }
);
#go {
  padding: 5px;
  border-radius: 5px;
  background-color: gray;
  text-decoration: none;
  color: black;
  text-align: center;
}
<div class="container">
        <select name="semester" id="select-semester">
            <option value="no-semester">select semester</option>
            <option value="semester 1">semester 1</option>
            <option value="semester 2">semester 2</option>
            <option value="semester 2">semester 3</option>
        </select>
        <a id="go" href="#" data-baselink="https://www.somelink.do/">GO</a>
    </div>

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