Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!