-
Having a math problem.
Maybe it's because it's Friday but my mind has totally gone blank and I'm hoping that someone can help me. I need to get these two variables to add together and the just want to be combined into one long number. Can anyone see what I'm doing wrong here? Thanks for any help. I think I need a beer.
Need a sum for val1 and val3 as stated.
level = document.form1.level.value;
rhr = document.form1.rhr.value;
mhr = 220-document.form1.age.value;
hr = mhr-rhr;
if (document.form1.level[0].checked){
val0 = hr * .5;
val1 = (val0+rhr);
val2 = hr * .64;
val3 = (val2+rhr);
Thanks for anything that anyone can do. I really do appreciate it.
Cheers and happy Friday.
-
Have you tried explicitly converting to a number format?
i.e. val0 = hr.todouble() * .5;
or something like that.
-
Actually, because these numbers all depend on what the user inputs they are all variable. I need to know the value of val1 not val0. val0 is working fine it's when I get to the val1=val0+rhr that I get the problem.
For instance if val0=65 and rhr=70, then I'm getting a value of 6570 for val1 and it really needs to be 135. What am I doing wrong?
Thanks
-
From what you just said, the problem is just what I said in my previous post. You need to convert the strings to doubles.
(Or whatever number format you want.)
-
Convert from char data
Try modifying your first two statements as shown here to force your variables to be treated as numbers:
level = document.form1.level.value - 0;
rhr = document.form1.rhr.value - 0;
Don't use the addition operator, as this may simply concantenate a zero-character onto the end of the string from the form.
Similar Threads
-
By Irina in forum ASP.NET
Replies: 0
Last Post: 11-29-2002, 10:47 PM
-
Replies: 0
Last Post: 12-13-2001, 12:06 PM
-
By Roseta in forum VB Classic
Replies: 0
Last Post: 11-14-2001, 03:24 AM
-
By Wade Balzer in forum VB Classic
Replies: 0
Last Post: 06-23-2000, 02:17 PM
-
By Jason Bock in forum VB Classic
Replies: 0
Last Post: 03-21-2000, 06:48 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks