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

137
Vistas
Javascript Variable and HTML

window.onload = function() {
    var today = new Date();
    var day = today.getDay();
    var daylist = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
    var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
    var datetime = date + ' ' + time;

    document.getElementById('display1').innerHTML = datetime + ' <br> Day: ' + daylist[day];
};
<tr>
  <td colspan="4" style="height: 26px">
      <asp:Label ID="display1" runat="server"></asp:Label>
  </td>
</tr>

I was wondering how do I display 'display1' in HTML Label? The is the HTML code and my objective is to input the date and time (Javascript) into the label (HTML). I have used "document.getElementById" code but I could not achieve the result that I wanted.

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

0

I tried your code in my computer and it's working as it should. Anyway if you want to print there the server date and time you should use the asp.net to create a date time and print directly. Instead if you want the client date and time you can remain on javascript but remove the label and set the id in the td directly

<tr>
 <td colspan="4" id="display1" style="height: 26px">
 </td>
</tr>
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