473,666 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Goal Seek" from Excel in Javascript

Does any one know how to create a function that works similar as "Goal
Seek" in Excel?

For example:
var a=8;
var b=6;
function c(a,b) {
return a*b;
}

And now I want that "c" will return me 56 and I want to do that only
by changing "b" and this "goal seek" function will return me solution
that "b" must be equal 7

I hope I didn't explain too chaotic.

I tried to find that on google but without any results.
Thanks in advance
Michael
Jun 27 '08 #1
3 10623
Michal meinte:
Does any one know how to create a function that works similar as "Goal
Seek" in Excel?

For example:
var a=8;
var b=6;
function c(a,b) {
return a*b;
}

And now I want that "c" will return me 56 and I want to do that only
by changing "b" and this "goal seek" function will return me solution
that "b" must be equal 7

I hope I didn't explain too chaotic.

I tried to find that on google but without any results.
Perhaps this for a start:

http://en.wikipedia.org/wiki/Newton%27s_method

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #2
In comp.lang.javas cript message <733f879c-e602-46dd-98aa-226d82210f4c@y3
8g2000hsy.googl egroups.com>, Fri, 16 May 2008 02:31:12, Michal
<re****@gmail.c omposted:
>For example:
var a=8;
var b=6;
function c(a,b) {
return a*b;
}

And now I want that "c" will return me 56 and I want to do that only
by changing "b" and this "goal seek" function will return me solution
that "b" must be equal 7
Go to <URL:http://www.merlyn.demo n.co.uk/js-demos.htm#FZ>, insert
in the textarea

function c(a,b) { return a*b; }
c(8, X) - 56

put Min X =, say, 0 and Max X = 50, press Find, and read the answer.

Then read the whole page, and View Source to find out how it is done :
it uses
function FindZero(F) { with (F) {
var j, X, XV, HV, LV, Fn = EX1.value
var Lo = userIn(Min1), Hi = userIn(Max1)
X = Lo ; LV = eval(Fn)
X = Hi ; HV = eval(Fn)
if ((LV*HV)>=0) { Ans1.value="Bad bounds" ; return }
for (j=0; j<40; j++) {
X = (Hi+Lo)/2 ; XV = eval(Fn) ; if (XV==0) break
if ((XV*LV)<0) { Hi = X ; HV = XV } else { Lo = X ; LV = XV }
}
Ans1.value="X = "+SigFigExp((Hi +Lo)/2, 8) } }
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, nr London UK. ?@merlyn.demon. co.uk IE7 FF2 Op9 Sf3
news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 27 '08 #3
On 16 May, 23:27, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
>...
...
Thank you Dr J R Stockton.
Thats something what I was looking for.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
It's not that I didn't read. I just couldn't find.. Maybe because my
"question" was bad :)

Thanks again

Michael
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2827
by: | last post by:
Could some help m figure out to strip an unknown range of characters in a path between the first "/" and "/" found in a folder path somewhere on my site. eg: /catamaranco/sales/boat/1.asp eg: /esserman/newseltter/2004/03/ eg: /yachtservices/excel/reports/ I wish to return only:
1
4466
by: jphelan | last post by:
I ran a MS Access Analyzer program that suggested changing, "rst.FindFirst strcriteria" to using the, "Seek" instead. I tried making the change. I get a Compile error that says, "Argument is not optional". Does anyone have any ideas on how I should change the FindFirst to using Seek the method?
5
1868
by: jensen bredal | last post by:
I need to keep track on user "session data" while still turning session off as i do not want users login to expire? Thanks JB
0
314
by: Felix Finch | last post by:
I have a perl test program which has about 80 test cases, each of which creates its own schema so I can remove them with DROP SCHEMA xxx CASCADE. Normally each test case creates and drops the same schema, but it can run a mode to preserve each schema and all the disk files for each test. I recently changed my cleanup code to run psql with all -c commands on one command line rather than a separate psql -c for each one ... psql -c 'DROP...
59
7492
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when the recordset opens a table. When I write Set rst = db.OpenRecordset("MyTable",dbOpenTable, dbReadOnly) I get an error. I believe it's invalid operation or invalid parameter, I'm
24
8204
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and seems to have a (tiny) amount overhead since window itself points to the global object, hence, a circular reference. (From everything I am reading, window is just a REFERENCE back to the global object, as opposed to a separate object.)
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.