Calculate The Percentage Of A Number?
Apr 12, 2011
I want to calculate the percentage of a number, but I'm getting a really weird result. In the following code f is equal to 3 and x.length is equal to 8. The part that isn't working is emphasised in bold. Basically 3/8 * 100 should result in 37.5 but the result I am getting with the following code is 7934570.3125. How do you calculate this percentage in Javascript?
function displaymember()
{
var m = 1;
[code]...
View 7 Replies
ADVERTISEMENT
Nov 2, 2011
I am using a JavaScript price calculator. Right now it does everything I need except for one thing.
If you look at the "type" field, they can choose either woven or printed. Right now, if they choose "woven" it adds 6 cents to to the total as you can see in this portion of the code:
if (theForm.select.value=="woven") {
priceeach+=0.06;
Rather than 0.06, how do I get it to add a percentage--say 20%
The form is located here: [URL]
View 3 Replies
View Related
Dec 8, 2009
I have a form that posts a Date In and a Date Out to another form. The variables are datein and dateout in format mm/dd/yyyy Trying to use this function to calculate number of nights :
Code:
<SCRIPT LANGUAGE=javascript>
<!--
function DateDifference()
{
date1= Date.parse(form.datein.value)
[Code]...
View 2 Replies
View Related
Sep 28, 2010
I want to calculate the number of days between two dates.
Date is in the below format:
First Date : 2010-09-27 05:00:00
Second Date : 2010-10-1 08:00:00
View 2 Replies
View Related
Feb 1, 2010
I need to find the average number in javascript. It is the only bit of javascript that I have to do in the course but it carries a high mark of which I cannot afford to lose. Any way the question is : "Write code to calculate the average height and write it out in the browser window"
<HEAD><TITLE> average</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
//Experimental results of Table 1 stored in arrays.
var Height = [15,16,17,18,19];
var Number = [2,1,6,4,2];
//Part (ii).
//Write code to declare and initialise new array to represent the third row of the table.
var avg = new Array(5)
var avg = ["60","80","187","180","114"] ;
avg[0] = "60";
avg[1] = "80";
avg[2] = "187";
avg[3] = "180";
avg[4] = "114";
//Part (iv).
//Write code to calculate the average height and write it out in the browser window.
avg = 0;
for (var count = 1; count <= 5; count = count + 1)
Array.average = function(){
var avg = 0;
for(var a = 0; a < this.length; a++){
avg += this[a];
} return avg / this.length;
};
document.write('average height is ' +avg + '<br>');
</SCRIPT></HEAD><BODY>
</BODY></HTML>
View 10 Replies
View Related
Oct 25, 2010
I am new to Java scripts. But at my job, my boss asks me to come up with a calculator that calculates the number of weeks on our website. But I want two calenders where in the first one the user will select the start date and in the second one, the user will select the end date. And There will be one last button that says"calculate" and a text box to display the number of weeks.
View 14 Replies
View Related
Sep 8, 2010
I have many inputs with name totalsum1,totalsum2,totalsum3 etc. I need to calculate number of inputs where name starts with "totalsum" and value is >0. I need to send result to another input with id="#rowtotal".My code:
$("#rowtotal").val(($("input[name^=totalsum]").val>0).size()); It's not working. Best RegardsRafa‚ Koszyk
View 1 Replies
View Related
Aug 3, 2010
For a project that would be too hard to explain, I am working with date ranges. There is a begin date and an end date. With those two variables, I need a function to calculate the number of months between both dates. To be more precise, I need a count of all unique month names in the dates (or month numbers if that is easier) where the range includes the beginning date, the end date, and all dates in between. So I am not looking for full months or an approximation. If only, say, one day of a given month is included in the date range, that adds a month. Also the range can span several years, january 2010 and january 2011 need to count for two different months.
View 2 Replies
View Related
May 24, 2011
Dont know if it can be done but.... I am using the percentage calculator
<SCRIPT language=JavaScript>
<!--
//Script by Tom Richardson Jr.
[code]....
View 2 Replies
View Related
May 4, 2011
I have a program in which a user must enter number of books and price and then calculate the total cost of the items, i have tried and tried to get it working to no effect can anyone see where i have went wrong.
View 2 Replies
View Related
Dec 6, 2010
I am having some difficulty in constructing a window.confirm() function that works with my code.So if the form data is valid, I need to use a window.confirm() dialog box to show the user's total cost based on the rental rate of equipment chosen and the reservation period. The user must accept the cost by pressing the confirm button, and if user cancels do not submit data.I have written this code but cannot figure out how to find the number of days from the 2 date fields and use that to calculate and display the total cost.
//confirm submit and display rental cost
var equip = document.forms[0].equipment.value
var pDate = document.forms[0].pickupDate.value[code].....
View 5 Replies
View Related
Jun 9, 2006
I am going to use javascript to calculate a value depending on what the user selects from a dropdown menu.
I have 2 columns in a table and a dropdown menu. The value in the 2nd column is going to be calculated by taking a percentage of the number that is hardcoded in the 1st column.
The user will select an option from the drop down e.g. 10% 20% 30% etc... and the value in the 2nd column will be calculated according to the percentage of the value in the 1st column.
View 1 Replies
View Related
Jan 26, 2010
I have divs on a page that are placed in the center with something like
width:100px;height:100px;position:fixed;top:50%;left:50%;margin:-50px, 0, 0, -50px;
I want to animate this div to the bottom left (similar tominimizingeffect on windows)
I am trying to use.animate({
opacity: 0.25,
left: '10px',
bottom: '10px';
height: 'toggle'
}, 5000);
However when I activate this it simply jumps (or glitches) to that position, the opacity and height animate perfectly.
View 1 Replies
View Related
Oct 27, 2010
I have a problem in my code which is as follows:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
[code]....
My problem here is that I am calculating the percentage values of a whole number and storing those values in text boxes respectively through javascript function.Now,what I need is that I want to round all the values to integer value such that the sum of integer values is equal to the final value.
View 2 Replies
View Related
Sep 21, 2009
I am having an issue with converting my decimal to a percentage. Below is my code:
(cost * .06) is where the issue is
var cost = prompt("What is the cost of your purchase?", "")
document.write("Return Value: "+cost,("<br />"));
var salestax = cost * .06
document.write("Return Value: "+salestax,("<br />"));
var total = cost + salestax
document.write(cost + salestax);
View 3 Replies
View Related
Mar 23, 2010
I am writing a form and doing a bunch of calculations one of which is a percentage based on the value selected. I am returning a correct result for two of the values but for the other two I am not.The 'discount' value is what I am looking for. It should return as 0 for values of 1 but it is doing the math as though it is multiplying by 1. And again for the value of 6 it should be 10% but is taking the value as 4.6 or something.Code is below I've included all of it (sorry) for better ease of understanding the math that is happening:
HTML Code:
<form id="form1" action="" method="get">
<fieldset>
<p>[code]......
View 3 Replies
View Related
Oct 27, 2010
I have a problem in my code which is as follows:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
[code]....
My problem here is that I am calculating the percentage values of a whole number and storing those values in text boxes respectively through javascript function.Now,what I need is that I want to round all the values to integer value such that the sum of integer values is equal to the final value.
View 3 Replies
View Related
Apr 7, 2011
so i am working on a calculator but i am having trouble with the % buttonif i do 200*50% it should be 100, but now it says 0.5the function code:
function PercentButton() {
if(NewNumber != "blank") {
Number2 *= .01;
[code]....
View 2 Replies
View Related
May 27, 2011
I'm working with a style.filter related function.Some of my function appear as ...
Code:
document.getElementById('audio').style.filter = 'progid:DXImageTransform.Microsoft.gradient(startColorstr=#A8' + c.substring(1) + ',endColorstr=#A8' + c.substring(1) + ')';
Everything is working but I'm trying to replace the "A8" part with a percentage typed in by the viewer.The percentage is simply a non-decimal number between 0 and 100 typed into a box.I know how to grab the value of the box (again, it's 0-100) but how do I convert that number into it's "A8" equivalent?
View 3 Replies
View Related
Dec 16, 2006
I am wondering if anybody can provide statistics what is percentage of visitors with disabled JavaScript.
Even more interesting would be statistics of users with disabled JavaScript making a purchase. I am more likely to purchase from my home than from work and I think the disabled JS is mostly result of IT dept. policies.
Is e-commerce site missing much if requires JavaScript?
View 7 Replies
View Related
Apr 4, 2011
I'm stuck on how to calculate the payment fee of 1.61% on top of the membership price. Also, how do I round the figures to 2 decimal places?Here's the Javascript so far:
<script type="text/javascript">
var member_prices = new Array();
member_prices["no"]=235.00;[code].....
View 10 Replies
View Related
Dec 1, 2011
I am implementing a zoom in feature, but actually tricking the user as a full screen image is simply being stretched.
I plan to apply it to several pages, and don't really fancy working out the pixels for each.
I believe that if you simply put width: 150% height 150% it will change the image size relative to the browser. I don't want that, I want it relative to the original image size. Could I do sort of height*1.5 or something? How would I write that if so?
<script>
$('#in').click(function() {
$('#drag img').animate({
width: '150%',
[Code]....
View 2 Replies
View Related
Mar 25, 2009
I didn't write much of this code, but basically, it opens an image in a new window. The problem is that the new window can either be the whole page, or a certain set size. I would like to make the window height and width determined not by a pixel number, but by a percentage of the size of the image I am opening in the new window.
here is the piece of code I think is pertinant.
// Strip file name from image src
var spath=targ.getAttribute('src');
wholePathLength=spath.length;
strippedPathLength=spath.substring(0,spath.lastIndexOf("/")).length;
[Code]....
View 10 Replies
View Related
Sep 21, 2009
How can i "prompt the user for the sales tax rate as a percentage"? this is what i have so far....
var tax = prompt("What is your tax rate percentage?", "")
document.write("Return Value: "+tax,("<br />"));
View 2 Replies
View Related
Jan 11, 2010
I am trying to customize this scrollbar so that it will fit all screen resolutions and I was wondering how I could do this by somehow customizing the JavaScript files created by Nathan Faubion or if I could do this using other JavaScript variables (var widthPercentage) to change the pixels to percentages?One of the pages on the website I'm using the JavaScript on
JavaScript file jsScroller.js:
//Created by Nathan Faubion http://www.n-son.com/scripts/jsScrolling/
function jsScroller (o, w, h) {
[code]....
View 6 Replies
View Related
Mar 26, 2010
I'm setting position left to 100% and it works except in Chrome/safari. These browsers set it about 100px from the left not 100%obj.css('left', '100%');Setting the css by itself <img src="" style="left:100%;position:absolute" works fine.I don't know if this is a browser problem or a jquery problem.
View 1 Replies
View Related