Calculating Root Values Beyond Math.sqrt

Dec 14, 2007

Well, it's been a while since I last visited CF, but I'm finally back and, for the life of me, am drawing a total blank on something that seems like it should be fairly easy to handle.

The Math.sqrt() function works just fine if all a person needs is the Square Root of a number, but what about needing the Cube Root or even a 4th Root of a number?

My first instinct was to use the Math.pow(x,y) function with a negative value for "y." For instance;

var z=Math.pow(27,-3)

This should return a value of 3. Unfortunately, this doesnt seem to work when I tested it through the W3 reference pages, so I am looking for a clue as to how I might go about finding such values, or if it is even possible through Javascript.

View 2 Replies


ADVERTISEMENT

Calculating Input Fields - Get The Math Function To Calculate And Display Properly

Nov 5, 2009

I can't seem to get the math function to calculate and display properly. Can anyone point me in the right direction.

Here is my code.

View 2 Replies View Related

Math Equation Getting Values From Form Fields?

Dec 8, 2010

I am having some trouble trying to fix my math equation to calculate the total rent by aquiring values from my form fields. Converting the date fields to days and finding the number of days via two date fields is mainly where I am having trouble. Also, I am trying to have a window pop up before submission but the onclick event does not seem to function properly.Below is the math equation I have come up with:

//calculate days from date field
function calcTotal(date1, date2) {
//assign variables

[code]....

View 3 Replies View Related

Calculating A Score From A Row Of Drop-down Values

Aug 11, 2006

I need help in calculating a score from a row of drop-down values.
I need to use the onChange to tally the score as the user moves across
9 categories (with drop-down selection of 1-9 or N/A) multiplied by a
weighted score. The final column for each employee would be the
calculated score. I know how to accomplish this with vbscript but I
need it to process on the screen so the user can see the calculated
score as they make selections. Also the code needs to execute as many
times as there are employee rows.(loop) I don't know how to do this
with Javascript

Here's the VBscript with the variables involved
Var S1 = Category 1 Weighted score
Var S2 = Category 2 Weighted score
Var S3 = Category 3 Weighted score
Var S4 = Category 4 Weighted score
Var S5 = Category 5 Weighted score
Var S6 = Category 6 Weighted score
Var S7 = Category 7 Weighted score
Var S8 = Category 8 Weighted score
Var S9 = Category 9 Weighted score
D5 = 0.92
Var Q11 = Category 1 drop-down Value(1-9) * S1
Var Q22 = Category 2 drop-down Value(1-9) * S2
Var Q33 = Category 3 drop-down Value(1-9) * S3
Var Q44 = Category 4 drop-down Value(1-9) * S4

If (Category 5 Value = "N/A") THEN
Q55 = ' '
Else
Var Q55 = Category 5 drop-down Value(1-9 or N/A) * S5
End If

Var Q66 = Category 6 drop-down Value(1-9) * S6
Var Q77 = Category 7 drop-down Value(1-9) * S7
Var Q88 = Category 8 drop-down Value(1-9) * S8
Var Q99 = Category 9 drop-down Value(1-9) * S9

If (Category 5 = "N/A") THEN
Var FinalScore = round(((Q11 + Q22 + Q33 + Q44 + Q66 + Q77 + Q88 + Q99)
/ D5),2)
else
Var FinalScore = round((Q11 + Q22 + Q33 + Q44 + Q55 + Q66 + Q77 + Q88 +
Q99),2)
end if

Can anyone help me converting this to javascript?

View 1 Replies View Related

Calculating Values From Radio Buttons?

Mar 15, 2009

I have an assignment in which the person has to choose their department and their hourly wage is given for each department. In the text box they must put their hours worked for the week, which I can't seem to get to work this is what I have:

<form id="employeeGroup">
<table width="398" border="0" align="center" cellpadding="10">
<tr>[code]............

View 4 Replies View Related

Exploding Values And Calculating Totals ?

Apr 1, 2009

I have a slight problem with creating dynamic quotes. Basically I have two select boxes and need to calculate a total in real-time using javascript and insert into input.First it needs to explode out the machine price and term years from the values and then calculate.

Here an example: A machine costs �4000 and a term of 2 years(60 months). The calculation would be (4000/60)*3 = �200

<select name="machine">
<option value="2005 - Almida XAS47 (660 Hours) �4000">2005 - Almida XAS47 (660 Hours) �4000</option>
</select>[code].....

View 6 Replies View Related

Calculating Values Of Columns And Rows According To Formulas?

Sep 26, 2010

calculating the summed values of a column. Also, the row values are subtracted from each other eg:

col1 col2 col3
row1 a b = a-b
row2 c d = c-d
row3 =a+c =b+d =a-b+(c-d)

however there can be N number of rows. I have listed below and example I have done to calculate the subtracted values but I am having difficulty doing the summations.

<table width="362" border="1">
<tr>
<td width="91"> <input name='r1c1' onblur='function update_Total_r1c()' size='6' value=""> r1c1</td>

[Code]....

View 2 Replies View Related

How To Loop The Math.min And Math.max

Feb 20, 2010

the program that i want to create will first let the user input how many execution he want to perform and will determine the highest and lowest number that he inputted.

for example.

prompt: how many execution you want to perform?
i type: 5
prompt:input number:10
prompt:input number:8
prompt:input number:5

[Code]....

but it only allows for the up to inputs[6] and the code is very long. i think i can use looping in it. but i dont know to use looping in math.min and math.max.

View 4 Replies View Related

Javascript Square Root

Dec 12, 2006

I cannot manage to do a square root operation. I am using the coding:

var a = Math.sqrt(b);

View 3 Replies View Related

How To Find Website Root Path

Jul 23, 2005

I have a problem with an application i'm working on (Asp.net using
vb.net for developing). I'm normally used to doing middle tier
development, so my javascript skills are not up to par. Here is my problem:

I have a javascript file called 'PMP/Scripts/Popups.js' (pmp is the root
of the website). In that file is the following function:

function OpenTutorial(sTutID)
{
var sURL = '../support/tutorials.aspx?tutid=' = sTutID;
var sProperties = 'center:yes;etc..'
window.showModalDialog(sURL, self, sProperties);
}

where ../support is acutally pmp/support.

Most of the website pages are located in sub folders from the root of
the website. When editing is to be done on a record, a popup window is
called from the main page. the popup pages are in another sub folder
(i.e. pmp/review would be where review.aspx resides and the edit page
would be located at pmp/review/popups). We give the user a tutorial
icon to click on which calls the OpenTutorial function on a button click
event.

The problem is the tutorial popup page won't load properly when called
from another popup page. I've tried variations of location.href,
location.pathname, location.hostname etc.. but can't seem to get the
pages to open correctly. The most common error i get is that the url is
not correct. here is a sample of the urls being called by the function:

View 1 Replies View Related

How To Get The Root Domain And Implement It Into The Script

Oct 5, 2007

I code with javascript in ruby on rails. So I need to switch between localhost and my website. So the domain changes every time. What can I do, so that javascript grabs the root domain, so, lets say: Code:

View 2 Replies View Related

Javascript Document Root Or Parent ?

May 21, 2007

I have an html that has a form for example

<form method=post action=blah.html>
<input type=hidde name=myHiddenVar value=''>

blah blah blah

<iframe name=myiFrame frameborder=0 scrolling=no src="anypage.php">currently loading</iframe>

</form>

now in iFrame page (anypage.php) I want a button to control or SET the value of the main FORM (html page) and its variable myHiddenVar, for example here is what I tried and it didnt work...

in anypage.php I hade a button
<input type=button value=change onClick="javascript:parent.myHiddenVar=100">

but the aboue didnt work, is there anything like docuemtroot ?

View 1 Replies View Related

JQuery :: Using Closest() Method - Root 2 Don't Get Selected

Jun 16, 2011

I have the following script using the closet method. It works fine for the inner most li tags however the outer li tags don't get seen? So both Root 1 and Root 2 don't get selected but the Sub Cat 1 and Sub Cat 2 get selected fine. I'm sure I'm missing some code to make this work.

[Code]...

View 3 Replies View Related

JQuery :: Ignoring The Root Element When Passed Through Context?

Feb 4, 2011

jQuery is ignoring the root element when passed through context. Am not sure if this is intended behavior.[URL]

View 7 Replies View Related

Dhtml Content Not Working In Iframe (IE) But Works In Root Document?

Mar 3, 2010

I am using a dhtml "Image Slideshow", and I was really happy with I customized its layout to my needs, and it runs perfectly on FF and on IE (wich is very important for me, since in my country most of people still use IE). Check it hereHowever, when I insert the slideshow in my design, it stops working on IE (working in perfection on FF):I am using the original slideshow file in an iframe.(before I tryed to paste the code directly into the page, but it didn't worked, so I thought using an iframe would work, because the code of the original document would be intact)

View 5 Replies View Related

Make A Module To Swap Ads Randomly From Folder Named Ads On The Root?

Jul 12, 2009

i want to make a module to swap ads randomly from folder named �ads� on the root like,, the advertising are either .swf, or .gif all that i need is to play the swf (when one is finished it starts the other one.. till the display of all swf's)..

[URL]

The folder �ads� is supposed to have 5 ads, when it finished number 1... it start randomly until it finish displaying all the advertising swf... i dont want to display only one of the five ... but display all in a random way..may be i have to know the length of the swf (in seconds ) and when it is finished i want to display the second and third .... etc

View 1 Replies View Related

Embedd An Address Navigation Bar On Top Of Pages Visited From Root Site?

Sep 2, 2010

I have what some would identify as a Kiosk machine running a browser in full screen(true full screen, no address bar visible). It serves as an internet cafe machine, with unique users and a login system.

What I'm looking to do is when the user leaves the root site (via clicking a button), to embed a frame at the top of the page with an address navigation bar, so I can track the time the user spent browsing. I'm exclusively using firefox, and I'm not concerned with support for such functionality in other browsers.

I assume I can achieve this with javascript, jquery, or ajax, I'm just not sure which to start with and how to begin planning the execution.

View 2 Replies View Related

Help With Math.abs()

May 21, 2007

Anyone any idea why the Math.abs() isn't working in this code? I
thought it was supposed to convert negative numbers to whole numbers?

var se = [-27, -27, -27];
var time = 100
if(se[0] < 0){
Math.abs(se[0]); //<-- this isn't converting it to a whole number
se[0] += 1;
se[0] = (se[0]/(time / 4));
}

The result I get is -1.04 when it should be 1.12

View 5 Replies View Related

Math.random()

Jul 20, 2005

I remember there is a programming language where you can initialize the
random number generator, so that it can - if you want - give you the exactly
same sequence of random numbers every time you initialize it with the same
parameter. Can this be done with JavaScript? I couldn't find anything in the
documentation. Basically, what I want to achieve is to obtain always the
same sequence of random numbers for the same given initialization value (but
of course different sequences for different init values).

Can this be done in JavaScript?

View 23 Replies View Related

Extending Math Functions

Jul 23, 2005

Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels deep. In
that case you need much more ram than a PC has to store functions
calculated in loops so that you do not have to recalculate every time
you cycle through the nest of loops. Using a HD for storage to extend
ram is much too slow for many applications.

Some functions such as hyperbolic ones are easy to add, since they are
just simple combinations of the built in javascript math functions. I
have found a few examples on the web such as Bessel functions. I found
far fewer javascript math functions than I expected on Google searches.
Thus I have had to write several functions of my own.

See http://www.cwdjr.net/math/I0L0andI1L1.html for an example of two
"functions from hell" that are very difficult to evaluate. Fortunately
there are Fortran programs that can be used as a starting point. I was
able to modify the Fortran programs to work on javascript. I have used
these functions for technical applications in the past.

The page is set up to reject the NN 4 series, because it will not
support some of the script needed such as .toExponential(n) and
to.Fixed(n)for writing output in exponential or fixed format. I was
amazed that even the old MSNTV(former WebTV) set-top box, that no
longer is being made, will even support these output formats. I wonder
about IE4. If it will not support these output formats, I can easly
block it by checking for document.getElementById.

The code works properly on the latest versions of IE6, MSN9, Firefox,
Mozilla, Netscape, and Opera. I am not selling anything, so for a
special interest page such as this, I see no need to support older
browsers.

The advantage of doing math with javascript is that it is so portable.
You can do it anywhere you can use a computer, or you can do it on your
own local computer offline. There are several math programs for PCs
that will do very much more than you can hope to do with javascript.
Unfortunately the program I would like costs about US$ 1800. Also there
are versions you can install on a server, but these also are expensive.

View 17 Replies View Related

Getting Nan Error With Simple Math

Mar 5, 2010

why I am getting Nan

<script type="text/javascript">
var num1;
var num2;
var num3;

[Code]....

View 3 Replies View Related

Firefox Math Messing Up Somehow?

Jun 18, 2010

<script type="text/javascript">
function countItDown(){
var current=parseFloat(document.getElementById("currentsecondscount").value);
var seconds=current;
document.getElementById("debug").innerHTML="S "+current;
var minutes=Math.floor(seconds/60);

[Code]...

im not sure why Firefox is doing this. it seems to work fine on Firefox 3.6.3 for Mac.

View 14 Replies View Related

Change CSS Property With Math?

Nov 23, 2010

I have this simple manual photo slide show. It shows four photos and when you click the next button and it moves one photo over and one photo back for the previous button. I have to moving by changing the CSS property of 'left' by 195 pixels each move. So for it to move next it will subtract 195 pixels from the left property and for moving back it add 195 pixels to the left property. I have the code setup so when you click it changes the property of left to either -195 or 195 pixels but I need it so it actually does the math, not just give it a set value. But I don't know how to do that.code...

View 3 Replies View Related

Allow Math To Be Eval'ed - But Not Malicious ?

Feb 10, 2011

I have a website that allows users to enter complex mathematical formulas into a text field and evaluates them.

I am currently using eval() because it not only can handle all the standard mathematical functions, but also gives them access to the Math object. That way the users can use functions such as Math.max() and everything else.

I realize, though, that using eval is evil, I assume because a malicious user might throw in some more damaging javascript that would be run without checking it. (That's why eval is evil, right?)

Is there a way that I can allow my users to construct complex mathematical formulas and use the Math object (or an equivalent) without potentially opening my site up to harm?

View 3 Replies View Related

Still Can't Fix Math.round / Make It Possible?

Nov 8, 2011

Just started to learn java & came up with the following, but can't get the math.round to work. Anyone able to tell me where I'm going wrong please ? code...

View 9 Replies View Related

Math Base 2 Logarithm?

Nov 10, 2005

If I have the following

2^n=a

javascript:Math.pow(2,n)=a;

and I now a how do I then find n with javascript?.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved