Negative Percent Work Around?
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
ADVERTISEMENT
Apr 1, 2010
I'm using this plugin:I was wondering if anybody knew of a way to place a percent mask on one input field that can have the possibility to be in both of these formats..
field
<input type="text" id="interest_rate" />
mask
[code]...
View 1 Replies
View Related
Feb 23, 2010
function update(value1){
doAjax("behind_scan.php" , "id="+value1);
}function doAjax(url , str ){
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null){
alert ("Browser does not support HTTP Request");
return;
}url=url+"?"+str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}function stateChanged(){
if (xmlhttp.readyState==4){
//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
//alert(xmlhttp.responseText)
document.forms.myform.scanner.value = "";
document.forms.myform.scanner.focus();
}}function GetXmlHttpObject(){
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}if (window.ActiveXObject){
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
} return null;
}
This pages calls a function on a separate php page to run 2 mySQL queries, the value must be put in the text 3 times in quick succession before the database is altered. I've tried all the other functions and they seem to be fine, AJAX is my weakness but I need it for the main functionality of my website. I need this to work.
View 2 Replies
View Related
Jul 1, 2011
I have 2 things going on here. One, the 'percent' variable is constantly showing up as NaN (not a number) no matter what numbers I give it. I suspect it is happening because the function is populating all the fields at one, which causes a 'divide by zero' scenario for the percentage field, which is last in line. Which brings me to my send thing. How to write this function correctly, as it obviously is causing problems as is, and it seems clunky. I think it should broken up into a couple different functions, but I tried that and NOTHING worked.
Here is the code, let me kow what you think:
function calculate(){
var contractsAdded = document.forms[0].contractsAdded.value;
var priceAdded = document.forms[0].priceAdded.value;
var contractsSold = document.forms[0].contractsSold.value;
var priceSold = document.forms[0].priceSold.value;
var totalAdded = (contractsAdded * priceAdded) * 100;
var totalSold = (contractsSold * priceSold) * 100;
var gainLoss = totalSold - totalAdded;
var percent = gainLoss / totalAdded;
document.forms[0].totalAddedCost.value = totalAdded;
document.forms[0].totalSoldCost.value = totalSold;
document.forms[0].gainLoss.value = gainLoss;
document.forms[0].returnPercent.value = percent;
}
View 4 Replies
View Related
Mar 25, 2010
I am using Javascript to generate a SQL query. When querying, I DO want asterisks to serve as a wildcard, but do NOT want percent signs to do so.
So, I have some code like this code...
But the above replaces asterisks with "!%" also! That's exactly what I don't want to have happen!
Does anyone know what I am missing here?
View 1 Replies
View Related
Jan 10, 2010
right now im using a percent bar to redirect the page when all buttons are clicked but i want a more efficient way of doing the redirect there will be a total number of buttons on my page, for examply 5 every time one is clicked, is there a possible way of subtracting 1 and when buttons = 0 the page redirects
View 1 Replies
View Related
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
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
Jun 14, 2010
The "Permission denied" cross site issue.
I have to check from my external domain if a service is running on localhost:8080 of a local machine.
I'm using XMLHttpRequest to do it.
I'm checking a local-web-server, not a file.
Every browser doesn't work, but Firefox. So I'm looking for a work-aorund.
An iframe? a flash swf? an applet java? HTA applications?
A side question is, why does FF work? Because it's a local-web-server?
View 2 Replies
View Related
Mar 30, 2010
I cant get my cookie to work. I believe its not my javascript that is wrong. Can anyone take a look to see what i did wrong in my cookie? I have to pages dropdown1.html and dropdown2.html. Both pages have the same exact dropdown list. There is also a javascript file called script.js which makes it so you get an error if you select the same option on the second drop down list as the first. Also in the script.js i have a cookie that should run so dropdown2.html should now what was selected in dropdown1.html Can anyone see if i made a mistake in either my javascript code in my cookie? Right now I am not getting the error message if you select the same option as the first. Ill show all my code incase you need it for reference
dropdown1.html
Code:
Code:
Script.js (this is the part where I cant figure out why the error message does not appear on the second dropdown menu if user selects the same option as the first)
Code:
View 4 Replies
View Related
Jan 12, 2011
I have a problem, I don't know why this code doesn't work on IE ver 8 On Firefox, Chrome it is like I want, on IE - no reaction Is this some html/css problem or my fault on js? I'm sure about .js code is correct.. I think.. link html/css/js
View 6 Replies
View Related
Mar 15, 2011
this will not work on change. also the innerhtml wont display. please help. here is the js:
function checkemail(){
if (document.suform.email.value && document.suform.emailcheck.value)
{
if (document.suform.email.value == document.suform.emailcheck.value)
[code]...
and here is the html:
Re-type Email: <input type='text' class='rfield' name='emailcheck' id='emailcheck' onchange='checkemail()'></td><td style='position: relative;'><div id='wm' style=' font-size: 11PX; position: relative;'></div>
View 4 Replies
View Related
Feb 25, 2004
can i use x on top of cbe versions prior to 5? will this cause any conflicts and break anything? is there anything i need to be aware of or watch out for?
View 2 Replies
View Related
Jul 23, 2005
Here is the layout of my form from left to right, from top to down.
- buttonA, buttonB, buttonC
- textbox, textbox, textbox
- buttonXXX
After the user types in the textboxes and press enter (with the cursor still
in one of the textboxes), buttonXXX should be pressed by default.(the user
is too lazy to take the cursor over to buttonXXX and click).
The problem is the top/left most button (button A) gets pressed which annoys
them to death. So I tried to do this.
In the bottonA's onfocus event handle-
document.forms[0].elements['buttonXXX'].focus() .
Result: ButtonXXX receives focus alright, but the code for buttonA still
executes!
View 1 Replies
View Related
Apr 11, 2006
The following passes the test as valid, and the mouseover for the six
indicated areas also work.
I need various areas to link to another page, including the six
mentioned.
However either the MAP works by itself, or the below mouseover works,
but not both. Code:
View 11 Replies
View Related
Jan 19, 2007
The last time I tried to ask this question...Google Groups screwed up
my message and there was no subject (sorry for that - I know it's
annoying).
I'm trying to learn how to develop a plug-in that allows users to
display data from one site in a third party site, like Google Adwords
or the Digg counter for news stories. I took a look at Digg.com and
found the following:
It looks like digg is doing the following to show the number of "diggs"
for a story on your website. On my page I would have the following:
View 2 Replies
View Related
Jul 20, 2005
I did a clean install of Windows XP on my computer and my javascript will
not work. I've tried all types of browsers, I've download the Service pack
1 for XP and IE. I have download java from Sun, which I know is not
javascript but it could not hurt. I have done everything I know of to fix
this problem but still Javscript will not work on my windows XP. I don't
know where to turn from here, Microsoft surely does not have any info about
on their website....
View 4 Replies
View Related
Jul 20, 2005
I've written some kind of menu to display a diagram with input fields
for a budget plan. A user should be able to change values, which are initially filled by
a database value, and get all corresponding values filled by the
program.
//value given by database
showText[k].setAttribute("value", eval("liste[i][TEXT" + k + "]"));
//onchange event for the user to change the value
showText[k].setAttribute("onchange", "calculate('cost" + i + "')");
//function to recalculate corresponding values
function calculate(myId) {
if (myId == "initial") {
...
}
else {
myId = myId.slice(4);
//getParents(myId) returns corresponding values for myId
var myParents = getParents(myId);
for (var i = deep; i >= 0; i--) {
var sum = 0;
for (var j = 0; j < myParents.length; j++) {
...
for (var k = 0; k < children.length; k++) {
sum +=
parseFloat(document.getElementById(eval("'cost" + children[k] +
"'")).getAttribute("value"));
}}}}}}
My Problem is:
IE and Netscape always use the value initially entered by the database
and not the new value entered by the user.
Is there a timing or DOM problem?
View 5 Replies
View Related