Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-28-2004, 01:20 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 203
falsepride is on a distinguished road
Adding Variable Numbers

in a script im writing, i need to add and multiply variables that represent numbers. how do i add the numbers together, everything i try just attaches the variable on the end of the other.
falsepride is offline   Reply With Quote
Old 10-28-2004, 01:23 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
check this code out.. you probably need to use 'parseInt' on your variable because javascript thinks it is a string.
HTML Code:
<Script language="Javascript">
var a = "1";
document.write(a+9);
document.write("<br>");

var c = parseInt(a);
document.write(c+9);
</script>
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP N00b - How to check if a variable is set? or empty? helz MS Technologies ( ASP, VB, C#, .NET ) 3 11-04-2004 10:19 AM
adding numbers doesn't add up !!! help arwilliams HTML, XML, Javascript, AJAX 3 09-30-2004 10:17 AM
Changing variable type for edit box : mfc - .net sde Standard C, C++ 0 01-31-2003 09:53 AM
creating dynamic variable names sde PHP 5 11-02-2002 09:03 AM


All times are GMT -8. The time now is 02:00 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting