Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old January 10th, 2008, 08:31 AM   #1
New Member
 

Join Date: Jan 2008
Location: Paris
Age: 27
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Scream is on a distinguished road
[SOLVED] Problems with arrays

Im trying to learn JS and currently working on arrays, im making a emulation of a browser which has 3 arrays a current array, forward and back.
I seem to have problems when i its making a blank entry to begin with and not operating correctly.

Code:
<html> 
 
<head>
<script>
    var Display=new Array ()
    var BackStack=new Array ()
    var ForwardStack=new Array ()
 
 
    function ClickEnter(){
 Display.pop();
  Display.push(myTest.url.value);
 if (BackStack == undefined)
 myTest.content.value=Display; 
 else
 BackStack.push(myTest.content.value);
 myTest.back.value=BackStack;
 myTest.content.value=Display;
 for (var i=0; i < ForwardStack.length;){
 ForwardStack.pop()
 }
 myTest.front.value=ForwardStack
        }
 function GoBack (){
         ForwardStack.push(Display);
  Display.pop();
  var catchpop = BackStack.pop();
  Display.push(catchpop);
  myTest.back.value = BackStack;         
  myTest.front.value=ForwardStack;
  myTest.content.value = Display;
            }
 
    function GoForward (){
          BackStack.push(Display);
  Display.pop();
  var catchpop2 = ForwardStack.pop();
  Display.push(catchpop2);
  myTest.back.value = BackStack;         
  myTest.front.value=ForwardStack;
  myTest.content.value = Display;
                    }
 
</script>
<title>THE BROWSER EMULATOR</title>
</head>
 
<body>
 
<p align="center"><b><font size="5">THE BROWSER NAVIGATION DEMONSTRATOR</font></b>
<form name="myTest">
 <p align="center"><b><font size="2">URL:</font></b> 
 <input name="url" type="text" size="20">
 <br><BR>
 <input type="button" value="Enter" name="Enter" Onclick="ClickEnter()"></p>
 <p align="center"><b><font size="2">DISPLAY:</font></b> <input name="content" type="text" size="20"></p>
 <p align="center"><textarea rows="8" name="back" cols="20"></textarea>
 &nbsp;&nbsp;&nbsp;
 <textarea rows="8" name="front" cols="20"></textarea></p>
 <p align="center"><input type="button" value="Backward" name="Backward" Onclick="GoBack()">
 <input type="button" value="Forward" name="Forward" Onclick="GoForward()"></p>
 <p>&nbsp;
</form>
 
</body>
 
</html>
Scream is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 10th, 2008, 09:16 AM   #2
Highly Reputable Member
SuperMember
 
Rakuli's Avatar
 

Join Date: Sep 2007
Location: Australia
Age: 25
Posts: 954
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold Rakuli is a splendid one to behold
Re: Problems with arrays

So what exactly is the problem you are getting? Unfortunately "not working correctly" doesn't help me a great deal and I haven't become intimate with your code as yet..

Can you explain what is breaking your functionality?

Cheers,
__________________
Luke Dingle . com
Rakuli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 10th, 2008, 12:15 PM   #3
New Member
 

Join Date: Jan 2008
Location: Paris
Age: 27
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Scream is on a distinguished road
Re: Problems with arrays

Sure,
For example if i enter into the program, 1, 2 and 3.
1 and 2 would move to the BackStack (which works) although it creates a blank entry aswell.

But when you press the backwards button (GoBack function)
The program should move 2 into the display(myTest.content) and move 3 into the FrontStack and remove 2 from the BackStack.

What it is actualy doing is moving 2 in the FrontStack not 3, although it does complete the rest.

If Backwards button is pressed again it gets even worse and i get 1,1 in FrontStack and 1 in display. Backstack is corretly empty.

The same issue is happening with the forward button although in reverse.

Regards
Scream is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fly-out menu problems karinne HTML, XHTML and CSS 13 January 30th, 2008 09:45 AM
[SOLVED] [C#] Having some problems. alexgeek Other Languages 6 November 15th, 2007 01:48 PM
[SOLVED] Problems with centering in CSS. mcdanielnc89 HTML, XHTML and CSS 26 November 1st, 2007 03:07 AM
Looping through arrays assgar Your Design and Layout 1 April 22nd, 2007 02:43 PM
arrays? macupryk .NET 1 September 30th, 2003 08:44 AM


Search Engine Optimization by vBSEO 3.2.0 RC8