web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Javascript code works ...
Power Pages
Answered

Javascript code works in console but not in js file for portal webpage

(0) ShareShare
ReportReport
Posted on by 134

Hi everyone,

I have a webpage recording invoices details in power apps portal.

Quantity value is displayed as "1.00000", so I tried deleting extra 0 after decimal point through the below code.

Audreyma_0-1626161877912.png

 

When putting the code in chrome console, it works.  But including it in webpage's custom Javascript, it didn't.

document. ready was included as well, not sure about the reason.

$(function() {
 $("#invoicedetails td:contains('.00000')").each(function(){
 var txt = $(this).text();
 $(this).html(
 txt.replace(/\.00000/g,'')
 );
 });
});

Any idea, please kindly share with me.  Thanks in advance!

Categories:
I have the same question (0)
  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    Hi Audreyma,

     

    If you are using an entity list then probably the data has not been loaded yet when your code executes (on document.ready). You could try adding your javascript to the loaded event of the entity grid, either in the custom javascript of the page or the grid itself. Something like:

     

    $(document).ready(function (){ 
     $(".entitylist.entity-grid").on("loaded", function () {
     $(this).find("td:contains('.00000')").each(function(){
     var txt = $(this).text();
     $(this).html(txt.replace(/\.00000/g, ''));
     })
     })
    });

     

  • Audrey Ma Profile Picture
    134 on at

    Hi @Anonymous 

    Thank you for your advice.

     

    The table existed in an entity form.  I changed the code a little bit and it worked.

    Really appreciate your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 70 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard