Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
How to Combine 3 ID's when a button was clicked?

I've try this code


<p>Watch Series Online</p>
<input type="search" id="imdbseries" class="Search" name="" value="" 
placeholder="IMDB ID">
<input type="search" id="season" class="Search" name="" value="" 
placeholder="SEASON">
<input type="search" id="episode" class="Search" name="" value="" 
placeholder="EPISODE">
<button id= "search" onclick="search()" >Watch Now</button>
<script>
function search() {
  var imdbseries = document.getElementById('imdbseriesID','season#',episode#').value
window.location.href = "https://mysiteurl.com/tv.php?imdb="+ imdbseriesID + "&season=" + season# + "&episode=" + episode#;
}
</script>

but fail for 3 ID's..

I want that when I fill the box with IMDB ID:tt9140554 SEASON:1 EPISODE:1

it should go to this EXSACT URL when the button was clicked. https://mysiteurl.com/tv.php?imdb=tt9140554&season=1&episode=1

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your html

<p>Watch Series Online</p>
<input type="search" id="imdbseries" class="Search" name="" value="" 
placeholder="IMDB ID">
<input type="search" id="season" class="Search" name="" value="" 
placeholder="SEASON">
<input type="search" id="episode" class="Search" name="" value="" 
placeholder="EPISODE">
<button id= "search" onclick="search()" >Watch Now</button>

Your script

function search() {
   // The document.getElementById() takes one Id
   let imdbseries = document.getElementById("imdbseries").value;
   let season = document.getElementById("season").value;
   let episode = document.getElementById("episode").value;

   location.href = `https://mysiteurl.com/tv.php?imdb=${imdbseries}&season=${season}&episode=${episode}`

}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Here's the documentation for getElementById. As you can see it accepts only one argument.

An alternative is to use querySelector. (You can tidy up the markup a little by replacing putting the id values in the name attribute, and removing the ids altogether.) Then you can just target elements by their name attributes, grab the values, and then build a string.

(Note: at some point you may want to add some validation to check the input values are valid. For example, both season and episode should both be numbers.)

function search() {

  const imdbseries = document.querySelector('[name="imdbseries"]').value;
  const season = document.querySelector('[name="season"]').value;
  const episode = document.querySelector('[name="episode"]').value;

  console.log(`https://mysiteurl.com/tv.php?imdb=${imdbseries}&season=${season}&episode=${episode}`);

}
<input type="search" name="imdbseries" placeholder="IMDB ID" />
<input type="search" name="season" placeholder="SEASON" />
<input type="search" name="episode" placeholder="EPISODE" />
<button onclick="search()" >Watch Now</button>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda