Simple Fibonacci Recursion Problem
Apr 29, 2006
I have this script. It's supposed to give the Fibonacci numbers but the recursion won't work. It just prints out 1 number that the user entered and that's it. In IE6 it prints 1 number but in Firefox it prints the same number an infinite number of times. Whats going on? Here is the script:
<html>
<head>
<script language = "javascript">
function fib(form)
{
var fibVar = Number(document.myform.inputbox.value);
document.write(fibVar);
if(fibVar == 0 || fibVar == 1)
return fibVar;
else return fib(fibVar - 1) + fib(fibVar - 2);
}
</script>
</head>
<body>
<form name="myform" action="" method="get">
<input type="text" name="inputbox"><br>
<input type="button" name="button1" value="Calculate"
</form>
</body>
</html>
View 1 Replies
ADVERTISEMENT
Nov 15, 2011
[code]The last number in the sequence is 14472334024676220 when it should be 14472334024676221. Why does it round down and how do I fix it so that it no longer rounds the last number down?
View 10 Replies
View Related
Aug 1, 2007
I am trying to program a script that will output the solution for the towers of hanoi problem, the only problem is that it will not output the solution it just hangs while calculating. Code:
View 2 Replies
View Related
Oct 27, 2011
wanna know how we can get the animation effect using the recursion method. following is the code:
$(document).ready(function(){
$(".flip").click(function(){
$(".panel").slideToggle(2000); // i wanna call this jquery animation recursively
[code]....
View 1 Replies
View Related
Dec 9, 2011
I am trying to create a family tree, parents / grandparents etc, of a single person... My database etc is already working but I cannot find any working examples that I can make sense of... Each of my records has a name, dob and id of each parent.... How can I get X generations from this.. I thought something like this might work.. GetParents For each parent GetParents And so on... But I have no idea how to put this into code...
View 2 Replies
View Related
Jul 20, 2009
I am having a problem finding the syntax for recursively adding images to a webpage using javascript. I have some pseudo code but no js.
already in a folder function 1 for each file in folder add file to webpage next folder function2 function2 for each folder within folder call function 1
I know the code isn't all that clear, but that's the best way I can describe it.
View 3 Replies
View Related
Dec 29, 2009
I am having trouble with a recursive function I created to list out the indexes and values of various nested objects.
var macros={
CTRL: {
ALT: {
ENTER: "<br />",
P: "<p>.</p>",
A: "<a href="">.</a>",
_1: "<h1>.</h1>",
_2: "<h2>.</h2>",
_3: "<h3>.</h3>",
_4: "<h4>.</h4>",
_5: "<h5>.</h5>",
_6: "<h6>.</h6>"
}}};
I want to print out the whole 'bread crumb trail' to each object, ie CTRL ALT 6: <h6>.</h6>, but at the moment my function prints out CTRL ALT twice for 'ENTER' and then never again. The function:
function printObj(obj) {
for(i in obj) {
var n=i.replace("_", "");
document.write(n);
if(typeof obj[i]=="string") {
document.write(":");
document.write(" "+obj[i].replace(/</g, "<").replace(/>/g, ">"));
} else {
document.write(n);
}
if(typeof obj[i]=="object") printObj(obj[i]);
document.write("
");
}}
printObj(macros);
The current output:
CTRLCTRLALTALTENTER: <br /> P: <p>.</p> A: <a href="">.</a> 1: <h1>.</h1> 2: <h2>.</h2> 3: <h3>.</h3> 4: <h4>.</h4> 5: <h5>.</h5> 6: <h6>.</h6>
View 4 Replies
View Related
Oct 8, 2007
I am using the module pattern and private/public methods. I'm having a problem where the private method is using setTimeout() to call itself recursively, but I can't get the syntax right. Code:
View 1 Replies
View Related
Mar 20, 2011
Firebug returns an error and I like to ask you how I could improve my code.
[Code]...
View 3 Replies
View Related
Apr 24, 2009
I would like to know if there is a simple way to show all elements of that variable?
var collectionElements = {
teste: {
var1: 'teste[]',
[Code].....
With this function my firebug Console outputs only the last object(3th node) with its child object.
View 1 Replies
View Related
Dec 31, 2011
I am using jQuery form plugin to submit my form. It has a file element and when where I am submitting it I am getting "too much recursion" in Firefox. It looks fine in IE 8. It works fine if I submit the form without selecting any file.
I am calling ajaxForm() methid this way.
jQuery("#myForm").ajaxForm();
View 4 Replies
View Related
Oct 22, 2010
this code:
$(document).ready(function() {
$('body').click(function(evt) {
if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) {
$('a[href=#2]').trigger('click'); } });});
gives me and error of "too much recursion"
View 4 Replies
View Related
Sep 21, 2011
some "if" statements. I am writing a script to write to the document in hexidecimal numbers. I am probably going about it the long way. Keep in mind that this is only an excercise for me to practice recursion with conditional statements.
Here is what I got going on:
I see on my page: #00, #01, ... to #0f, Now, I would like to say:
Or something like:
At which point I would like to say:
The whole picture at the end would be #00, #01, all the way to #ff and back down to #00 again. WScript.Quit (Just kidding about WScript.Quit Lol!) That is unless javascript has access to Windows Script Host.
Anyway, After counting up to #ff, count back down to #00. Write all that to the document for proof and the script is done.
View 2 Replies
View Related
Jun 4, 2009
I have develop this javascript code [URL] This is a simple carrousel. I´m using JQuery 1.3.2. In the code you can see an array with images and the code is simply
changing the source of the img with the ID "carruselimg". I´m getting "too much recursion" y FF3 and "out of memory" on IE7 when this page is about 15 mimutes working.
View 3 Replies
View Related
Jul 23, 2005
I have a form1 with two fields, field1 and field2. I want the contents of field1 to be transferred to field2 onBlur, but with some changes. I want the contents of field1 to have its spaces replaced with Dashes, and all punctuation removed, so this can happen:
FIELD 1 value:
Today's rate is 15%, & the outlook is good.
onBlur should then create a value of:
FIELD 2 value:
todays-rate-is-15-percent-and-the-outlook-is-good
Notice that the "&" was converted to "and", the "%" to "percent". The comma
was deleted and all spaces replaced with Dashes. The second field should
only every contain alphabetic letter, dashes, and numbers.
View 3 Replies
View Related
Feb 20, 2006
I want to replace all occurences of this ),( in my string with a comma .....
statement=statement.replace("),(",",");
This only does the first. I've been reading about adding "/g", but haven't
got it to work. I've messed about with no luck. Any quick pointers?
View 2 Replies
View Related
Oct 2, 2006
i look for a simple ajax, for a beignner, able to send a request for a text file and show its content in a <div />.
View 6 Replies
View Related
Mar 18, 2003
Here's a small collection of bookmarklets for disecting your own (or other people's!) websites. They do things like, show all TABLE elements with a red border, hide non-link images, and so on...
View 23 Replies
View Related
Oct 26, 2005
i need a 5 second counter to start when the page loads. basically the usage is I want people to click a link, and if the page has been loaded for more than 5 seconds, do thisFunction().. if not, do nothing.
so basically
<script type="text/javascript">
window.onload --> start the counter
// when the counter hits 5 seconds, set var done = true;
function thisFunction() {
if (done = true) { proceed with function)
else {do nothing}
}
</script>
...
<a href="linkyPoo.html" onclick="checkCounter">OO oOO, click me!</a>
View 8 Replies
View Related
Jun 13, 2003
I'm trying to write some validation for a field called Propid, in a form called qSearch. Basically if there's nothing in Propid, or it is says "ref no.", I want to alert the user, otherwise, I want the form to submit.
Here's what I have at the moment:
Code:
<script>
function checksearch()
{
if (qSearch.Propid.value!="ref no." )
{
alert ("Select reference number" );
qsearch.Propid.focus();
return;
}
if (qSearch.Propid.length != 0)
{
alert ("Select reference number" );
qSearch.Propid.focus();
return false;
}
}
}
View 6 Replies
View Related
Aug 11, 2004
PHP Code:
<!--
function submitForm()
{
window.setTimeout(document.email_inner.submit(),5000);
}
//-->
im trying to submit my forum after 5 secounds of viewing the page and i have no knowlege of java wat fo ever but ey told me this is the onlyway to do such a thing ... this i wat i have so far in hte header .... it dose nothing at all
View 5 Replies
View Related
Apr 18, 2005
im tired of working all day...
please how to delete the value with regexp...
i tried this
bla.replace('value="/.+/"', '');
it wont work...
View 5 Replies
View Related
Apr 14, 2006
Just a few questions about simple animations (that aren't Flash). I've searched around but haven't been able to find anything really concrete about alternatives to JS. Basically in terms of simple animation, is JS the be-all-end-all? What other options are there in terms of simple animated menus (besides Flash & animated GIFs)?
Something like the above Quick Links menu; would something like that be possible in only Javascript? Or would there be an alternative?
View 4 Replies
View Related
Aug 21, 2002
I'm looking for a javascript that will do a 3 minute countdown and display it on the screen, preferably not in a textbox, but i'm not picky.
Here is how it works. Someone will make a selection from a form. The date/time of that selection is then stored in a database. I want to use the date time stored in the database as my starting time and then countdown 3 minutes. After 3 minutes I would like a message saying Times Up, please make a selection.
View 3 Replies
View Related
Nov 9, 2002
How do I use JavaScript instead of using this " <a target="_blank" href="http://www.OtherWebsites.com">Other websites</a> " if I want to use a list of JavaScript links?
View 3 Replies
View Related
Aug 31, 2009
Heres my code:
<html>
View 7 Replies
View Related