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

207
Vistas
How to make site more dynamic/save using same code?

I am currently working on a project, which has many html sites with the same structure. So the code is basically the same. The only difference these sites have, is that with each site I am accessing a different "partition" from my database. This is in the script tag:

<script>
    const api_url = 'urlhere';

async function getRating(){
    const response = await fetch(api_url);
    const data=await response.json();
    const myReviews = data;

  

    document.getElementById('Name').textContent = myReviews[0].PartitionKey;
    document.getElementById('Genre').textContent = myReviews[0].RowKey;
    document.getElementById('Seasons').textContent = myReviews[0].Seasons;
    document.getElementById('Description').textContent = myReviews[0].Description;
    document.getElementById('Rating').textContent = myReviews[0].Rating;
    document.getElementById('Review').textContent = myReviews[0].Review;

    console.log('Success');
}

The html part before contains things like images and a nav bar. But that is the same code every time. Is there a possibility that I can click on a button with the name of a show (e.g show 1) and that the show can be displayed dynamically via get parameter? ( Click on Button, Link changes depending on show -> http://www.test.com/index.html*?show=show1 , Website gets data from Database depending on Link)

Or do you have other solutions for my problem?

I hope you understand what I am trying to do, I am a beginner so I am not sure if I phrased it right or if it is even possible like that.

Happy for every answer!

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

0

Im not sure if i got your question right but im going to answer parts of it :

To get a query string value from the url in your case you want to get the 'show' parameter you could use :

const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());
const show_param = params.show ? params.show : "default";

And based on the 'show_param' variable you can change the source of your data or pass it as a parameter to your API end point

I'm not sure if the buttons 'show X' are in the same file if they are you can simply recall the function that gets the data and reset it to the respective elements.

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