HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 27th, 1999, 07:45 AM
Lisa1958
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I am doing so totaling on the fly with javascript. It works great in everything but IE3. Anyone know how I can get this to work in IE 3?

The error I get is (this line) "'value' is not a number"

document.input.f_stot.value= decimal(document.input.f_tot0.value * 1 + document.input.f_tot1.value * 1 + document.input.f_tot2.value * 1 + document.input.f_tot3.value * 1 + document.input.f_tot4.value * 1 + document.input.f_tot5.value * 1);
document.input.finalTotal.value=document.input.f_stot.value
}

I have tried all sorts of variations on this code to force Javascript to see it as a number but none seem to work.

thanks for any help!

Lisa

Reply With Quote
  #2  
Old April 27th, 1999, 11:21 PM
Alison
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
It's hard to tell what exactly is going on here without seeing it in context, but...

JavaScript considers any input from the user to be a string. So, you need to use something like the code below on each of your values to convert them to numbers.

var input0 = parseFloat(document.input.f_tot0.value)

You could also put parseFloat() around each of your values right when you do the calculation, rather than assigning them to a variable as I showed you above.

I assume you were multiplying each by one in attempt to convert them to numbers. Doing so is not necessary (since it won't work anyway).

Reply With Quote
  #3  
Old April 28th, 1999, 08:12 AM
Lisa1958
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I tried your recommendation and it worked great in IE3 which is where I was getting my error. But the same code gives me a NaN total in N4.5 which had no trouble with my original code.

new code:

newtotal = parseFloat(document.input.f_tot0.value) + parseFloat(document.input.f_tot1.value) + parseFloat(document.input.f_tot2.value) + parseFloat(document.input.f_tot3.value) + parseFloat(document.input.f_tot4.value) + parseFloat(document.input.f_tot5.value);
document.input.f_stot.value= decimal(newtotal);
document.input.finalTotal.value=document.input.f_stot.value}

I hate to put a "use 4.0 or higher" but I will if I have too!

Reply With Quote
  #4  
Old April 28th, 1999, 11:39 AM
Alison
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Since you've already converted your strings to numbers when you totaled them, you shouldn't need to do anything to the contents of your newtotal variable.

I'm not sure what you're using "decimal()" for, unless it's a custom function somewhere else in your code. (As far as I know, it's not a valid method in JavaScript.)

So, your next-to-the-last line of code should simply be:

document.input.f_stot.value = newtotal;

Reply With Quote
  #5  
Old April 28th, 1999, 12:07 PM
Lisa1958
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
"decimal" is a function:

// turn to decimal
function decimal(num)
{
string = "" + num;
number = string.length - string.indexOf('.');
if (string.indexOf('.') == -1)
return string + '.00';
if (number == 1)
return string + '00';
if (number == 2)
return string + '0';
if (number > 3)
return string.substring(0,string.length-number+3);
return string;
}

the same total is repeated in form.f_stot and form.finalTotal

Reply With Quote
  #6  
Old April 28th, 1999, 02:13 PM
Alison
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I made a minimal page in which to test your code, with six text input boxes to enter numbers in, and two fields to show the total. It worked fine in both IE 4 and Netscape 4.5.

So it seems that if you're still having problems, they are caused by something elsewhere in your page and/or code.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > IE 3 "'value' is not a number"


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway