Solved

remove trailing zeros in the string

Posted on 2009-05-19
3
457 Views
Last Modified: 2012-08-14
     if pageNumber comes as null i am assigning as 1;Let's assume that fin value is 10;then final output is coming as 010_1;
      i want to remove trailing zeros from the final output.
      
      var      pageNumber=document.forms[0].pageNumber.value;
            if(pageNumber == 'null' || pageNumber =="")
                  pageNumber=1;

                  var fin=10;

              addData += ((pageNumber-1)*10)+fin+"_"+pageNumber+",";


              alert(addData)
0
Comment
Question by:chaitu chaitu
3 Comments
 
LVL 14

Expert Comment

by:sam2912
ID: 24428716
I don't see any trailing zeroes in your example. Did you mean leading zeroes?
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 24428723
yes.
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24428727
Something like this?
<script>

var s;
 

s=((pageNumber-1)*10)+fin+"_"+pageNumber+","; //"010_1"
 

var regZ;

regZ=/^[0]+/;
 

s=s.replace(regZ,'');  
 

addData += s;

alert(addData);

</script>

Open in new window

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now