Can't Calculate A Negative Value
Jul 19, 2011
I have 3 textbox controls on my web page that are numeric currency fields in which a user can enter a numeric value, either positive or negative into TB1 and TB2 (both of these fields go thru edit checks to make sure a numeric value is entered and then return a currency value ie; $2500.00). TB3 is calculated resulting in TB3 = TB1 (($6500)) - TB2 ($2500).
My problem is that if a user enters a negative value for TB1, it returns a "NaN" and the value in TB3 turns out to be the same value as in TB2. Essentialy the calulation ends up being 0 - 2500 = 2500 (see screenshot). I've attached 2 functions below.
Code:
function cal_Overage_Shortage() {
if (make2Number("TB_LowPoint") <= 0) {
document.getElementById("TB_OverageShortage").value = GetValueTextbox("TB_LowPoint") + GetValueTextbox("TB_RequestedLowPoint");
[Code]....
View 1 Replies
ADVERTISEMENT
Jun 9, 2010
I have the following calculation (simplified to focus on the point):
Code:
var scroll_percentage = scroll_button_distance/scroll_wrapper_width;
or imagine this is:
Code:
var scroll_percentage = 100/500;
The answer is -INFINITY
How do I make this into a usable number?I searched for INFINITY and found plenty of info but am not sure how to simply get the "0.2" answer I need for the next calculations.
View 3 Replies
View Related
Sep 30, 2011
I occasionally need to set a negative margin on objects for positioning but 1.6.x ignores the declarations. This use to work fine with earlier versions. Has this issue been addressed? I tried all the combinations I could think of and the setting is ignored if a value is negative. (did not find a problem reference when setting a negative value in the forums)
$(objRef).css(marginLeft, "-20px");
$(objRef).css("margin-left", "-20px");
$(objRef).css(margin, "0px 0px 0px -20px");
[Code].....
View 1 Replies
View Related
Nov 7, 2011
If a negative number is entered into the reading variable it should be displayed as a zero. This works with the first calculations such as average but right at they very end the the alert wont display the highest average it just displays the one which has a negative number typed in to it.
[Code]...
View 11 Replies
View Related
Dec 20, 2005
I have a calculated value that is negative, which I need to display in a javacript prompt as positive. In ColdFusion, there is a function called ABS(), which gives you the absolute value of the number in question, so ABS(-5) = 5. Is there something similar in javascript? If no, how would I display a negative number without it's negative sign? Again, this is only for display purposes withing an alert.
View 2 Replies
View Related
Jul 6, 2011
I'm just starting out learning and have sort of given myself a couple of basic problems to solve. I pretty quickly found something that's apparently hard to Google.I've made a page that shows a counter number, starting at 0, with buttons that will increase or decrease the number by 1 or 10.So I'd like to figure out how to show that number in red when it is a negative number and in green when it is a positive number. I've tried a couple of things, including an if... else, but here's my latest crack:
var counter=0;
function countUp() {
lastCounter=counter;
[code]....
View 1 Replies
View Related
Jan 23, 2011
I've been trying to figure this out for hours. I want to write a js so that if the number in the 2nd column is negative, then the javascript changes the css color to red, so that the number is red. If the number is positive, then make it green. Do I need an array or loop, I just can't get anywhere.
Here is my code:
<!DOCTYPE html>
<html lang="en">
<body>
<table>
[Code]...
View 7 Replies
View Related
Jul 2, 2011
I have a function that does some calculations and populates some text fields with the results. I also have a function that changes the font color of the numbers to red if they are less than zero. What I dont have is a way to make them work together. I imagine I need to pass the results of the calculation function to the change color function, but not sure how to go about doing that. Here is the calculation function:
function to calculate the total costs, gain/loss and return percent.
function calculate()
{
[code]....
View 14 Replies
View Related
Dec 13, 2010
I have a problem in asp application validation. My textbox only accepts numeric value.It should not accept empty field and negative values and charcters.I am not aware of IsNan function.
View 8 Replies
View Related
Mar 28, 2007
Is there a way in a regexp to *not* match a fixed string value?
Using [^blah] gives matches to anything not containing *any* of letters
b,l,a and h. Whereas I want to match anything that does not containing
the exact string 'blah', i.e. *all* the letters.
Possible?
View 4 Replies
View Related
Feb 20, 2010
Hello everyone... I've got a question about an onKeyUp event. I'm using a text box that HAS to be a negative number therefore it has to have a - sign in front of the number. Can someone point me in the right direction as to how to write a function to do this? Thanks so much...
View 5 Replies
View Related
Sep 22, 2004
I want to add onto my ebay auction a calculation which would show the unit price of a box of 5 electrical sockets.
So say it is currently on auction at £5.62 and I charge £1.99 Postage & packing thats a total of £7.61 with a unit price of £1.52. Then £1.52 is the figure I want to output and show on screen.
View 2 Replies
View Related
Nov 20, 2002
I'm just starting out in JS and would like to know how to solve this.
I have an HTML form with 3 checkboxes, like a would-be order form. For example, on checkbox 1, the product is a toy car that costs $5.00, second box is a cigar cutter for $50, etc. I to have a button that when clicked, enters the total price (no taxes or subtotals) into a textbox field below in the same page.
View 3 Replies
View Related
Jun 29, 2006
I believe that this has been answered somewhere but I cannot find it. I have 51 textboxes on page. In 50 I can enter value. 51st should tell me what is average of entered numbers.
As user types I want script to iterate trough form count and sum non-empty fields and than divides this two numbers.I need to sum values from fields that have value (not emty fields) and to divide this number by number of non empty fields. This should occur on every change in any of those 50 textboxes so to have live preview of average.
I'm really new to JS and I don't know even how to sum these numbers.
View 5 Replies
View Related
Mar 6, 2010
I have some data thats in a number, lets say 5455
.
Id like to get the TAX from an input, say like 2.5 percent. code...
View 3 Replies
View Related
Jul 9, 2010
I want to calculate X and Y of a div, but I get an infinite loop, can you tell me please what's the problem with my code? code...
View 4 Replies
View Related
May 9, 2010
I built 2 steps script - in the first page the visitor choose the date he want to schedual his appoitment and his location:
PHP Code:
<select name='zone'>
<option value='-4' selected> USA - EST</option>
<option value='-7'>USA - PST</option>
[code]....
In the second page he need to choose the time he want for his appointment (the time is in GMT+3 -> my local time). in this page the script also get the time zone and the date that he choose in the previous page (using POST - PHP). the date saved in variable. I used unix time (MKTIME function) I want that every time my visitor choose time (from drop-down box) a new cell/DIV will appear with his local time.for example - when he choose date: 10 May 2010, time zone: Austrlia - East Coast (+8 Hours) and time 22:00, New DIV will appear with the date "11 May 2010, 03:00AM" (there are 5 hours different).what is the JS what caculate and show the visitor local time?(I have, in PHP, only his time zone and the date that he coose in the first page)
View 2 Replies
View Related
Apr 11, 2010
I have tried many time to make the calculation to appear at the total text box.
here is my coding..
<html>
<head>
<title>
PRESENTATION EVALUATION FORM
[Code]....
View 5 Replies
View Related
Apr 8, 2011
I'm working on creating a custom calculator to determine the amount of money / credits users may earn from referrals. I've tested onChange, and it will work only when I have changed to a new field or clicked off that field. How do I make this calculate live?
So if the current value is 5 and I change it to 6, it will automatically recalculate the new value.
You can see what I'm working on here:
[URL]
Note: The one I'm testing is the 1st Level field. For now i'm just having it display the date.
View 6 Replies
View Related
Feb 15, 2007
Can someone explain to me how I should code to calculate this?
I want to let the user add 4 different numbers (this is done) and then I want to + these numbers with each other.
This is the code I got: var medel = tal1+tal2+tal3+tal4 ;
Let say the user enters 1+2+3+4. Then the result should be 10. But I get this number as result: 1234
What have I done wrong?
View 2 Replies
View Related
Jul 26, 2011
I am making what I call a PM (Preventive Maintenance) Kit list. My users will use this list to generate a printable sheet to tell me what they used out of there kit. The list includes pricing per part and I would like the list to calculate the costing as they enter each item. So a total per line and an overall total cost.
I have included a snap shot of the page and below is the code. I can do this sort of thing on a small scale with just adding two lines but I am not sure how to modify it to handle this scale. You can see the script towards the bottom of the page. That is my lame attempt to make the per line costing happen but NOTHING happens.
<?php
require "../config/bpts_config.php";
// Start the session
//session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
[Code]...
View 4 Replies
View Related
Mar 31, 2009
This is my coding that I try but I still cannot get the function to calculate cgpa.
<script language="Javascript" type="text/javascript">
/*Gred*/
function DisplayGred (GredPair) {
var Gred = GredPair.split('|');
var jam_kredit = document.getElementById('jam_kredit').value; (user input pay amount student pay for course)
document.getElementById('pointer').value = Gred[1]; (display course fee when item is selected)
}
function CalculateCGPA () .....
This is the interface look alike, the code subject, subject name and credit hours are retrive from the database, so how to calculate it?
</p>
<form id="form1" name="form1" method="post" action="">
<table width="552" height="82" border="0" class="tborder">
<tr bgcolor="#006699" class="text2">
<td width="17" bgcolor="#000099"><div align="center" class="style3"><strong><font size="2">Bil</font></strong></div></td> .....
View 2 Replies
View Related
May 13, 2005
I want to have 1 option box with values 10 100 1000 10000 etc in it , then i want to be able to select eg 100 and underneath it will show 100x25 which would be 2,500 so i want 1 box that has values of ten , hundred , thousand etc and they multiply by 25 and show underneath .
View 3 Replies
View Related
Apr 28, 2009
Using this formula for parts per million, can somebody please show a SIMPLE example of how to calculate all formulas for ppm?i tried everything..like in kilograms, etc...anyway, the link:[URL]
View 9 Replies
View Related
Jul 23, 2005
For my website i would like to display the age of my son in years,
months, days and hours.
For now i manage to get a result for totals. Like the total number of
days.
This is the beginning:
starttime = Date.parse("Aug 10,2003, 07:07")
sdt = new Date(starttime)
starttime= Math.ceil((starttime) / 1000 / 60 / 60 / 24 )
ndt = new Date()
y = sdt.getYear()
m = sdt.getMonth() + 1
d = sdt.getDate()
h = starttime
View 26 Replies
View Related
Oct 6, 2010
automatically calculate a total. The script pulls a price, which is given from a database to a hidden form field. Then once the quantity is changed the bottom form field automatically updates the price. Here's my script if someone could possibly point out why this might not be working (or is my logic flawed.)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart</title>
<script type="text/javascript">
/* <![CDATA[ */
function calcTotal(){
[Code]...
View 3 Replies
View Related