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

185
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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