User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 392,070 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,270 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 551 | Replies: 3 | Solved
Reply
Join Date: Jul 2008
Posts: 9
Reputation: rejisha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rejisha rejisha is offline Offline
Newbie Poster

add two numbers

  #1  
Jul 15th, 2008
hi all....

i want to add 01+1 and my desired output is 02.

my code is
var t=01;
var t2=t+1;
alert(t2);

the alert value is 2.
I want 02....what will i do?
thanks in advance....
Last edited by rejisha : Jul 15th, 2008 at 3:24 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2008
Location: Delhi
Posts: 119
Reputation: vicky_rawat is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 15
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: add two numbers

  #2  
Jul 15th, 2008
Hi,

you can sumply use

   t2 = "0"+t2;

but if you also want to give a condition that a 0 will be prefixed only for numbers less than 10.

then
   if(t2<10)
    {
        t2 = "0"+t2;
    }
Vivek Rawat
Keep solving complexities.
Reply With Quote  
Join Date: Jul 2008
Posts: 9
Reputation: rejisha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rejisha rejisha is offline Offline
Newbie Poster

Re: add two numbers

  #3  
Jul 15th, 2008
thank you Mr:Vicky.....thanks a lot..............
Reply With Quote  
Join Date: Jun 2008
Location: Delhi
Posts: 119
Reputation: vicky_rawat is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 15
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: add two numbers

  #4  
Jul 15th, 2008
Hi,

always mark thread as solved, when you get solution, as it will help others if they are searching for a solution.
Vivek Rawat
Keep solving complexities.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 11:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC