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

187
Vistas
HTML + java script Count Row help and Javacript is not recognizable in HTML

I am a newbie in coding-some experience in python. Our company(Finance) is using software called Xceptor to process the data and adding the function of including the table in the message body with HTML. But one thing that really bothers me is when there's no information in the Listfield, I want to output text only and doesn't show the table. Display header and content when there is something, including a sentence indicating how many. Is it possible? Here is the sample script.It works well in W3 school editor but script part doesn't work in that platform I am using.Does any one have any suggestion for that? Thank you for your help and have a good one.

<table border="1" id="MyTable">
<p id="count"></p> 
    <tr> 
        <th>Record Type</th> 
        <th>Trade Date</th> 
        <th>Account</th> 
        <th>Transaction</th> 
        <th>Traded Asset</th> 
        <th>Proceed CCY</th> 
        <th>Settlement Date</th>
        <th>Quantity Traded</th> 
        <th>SHORTNAME</th> 
        <th>ACCT_ID</th> 
    </tr> 
    {[List Field]}  
</table>
<script>
var rowCount = document.getElementById("myTable").rows.length;
if(rowCount <= 1 ) {
document.getElementById("myTable").style.display = "none";
} else{
document.getElementById("count").innerHTML = "There are "+(rowCount-1) +"row(s)";}
</script>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Identity strings are case sensitive. You misspelled it in your version. With document.getElementById("MyTable"); it will work:

const tbl = document.getElementById("MyTable"), rows=tbl.rows.length-1
if(rows)
 document.getElementById("count").innerHTML = `There ${rows==1?"is one row":`are ${rows} rows`}`;
else tbl.style.display="none";
<p id="count"></p>
<table border="1" id="MyTable"> 
<tr> 
    <th>Record Type</th> 
    <th>Trade Date</th> 
    <th>Account</th> 
    <th>Transaction</th> 
    <th>Traded Asset</th> 
    <th>Proceed CCY</th> 
    <th>Settlement Date</th>
    <th>Quantity Traded</th> 
    <th>SHORTNAME</th> 
    <th>ACCT_ID</th> 
</tr>
<tr> 
    <td>Type</td> 
    <td>Trade Date</td> 
    <td>Account</td> 
    <td>Transaction</td> 
    <td>Traded Asset</td> 
    <td>Proceed CCY</td> 
    <td>Settlement Date</td>
    <td>Quantity Traded</td> 
    <td>SHORTNAME</td> 
    <td>ACCT_ID</td> 
</tr> 
{[List Field]}  
</table>

about 4 years ago · Juan Pablo Isaza Denunciar

0

HTML is a markup language and not programming language so you cannot use if statements in HTML. You will need to do it with help of Javascript.

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