Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:47:53+00:00 2026-06-18T10:47:53+00:00

I’m working on a wizard that uses javascript to change the page in an

  • 0

I’m working on a wizard that uses javascript to change the page in an iframe. I’d like to create an object for each page of the wizard with references to a next & previous page.

Edit: The code posted below does not work. actionOne.nextAction is equal to {} after execution.

var actionOne = {};
var actionTwo = {};

actionOne = {
    url: 'actionOneUrl.htm',
    prevAction: null,
    nextAction: actionTwo,
    doDisplay: function(){
        $('.label').html('Action One');
    }
}

actionTwo = {
    url: 'actionTwoUrl.htm',
    prevAction: actionOne,
    nextAction: null,
    doDisplay: function(){
        $('.label').html('Action Two');
    }
}

The problem is that I can’t figure out how to properly set up the next and previous references. There is likely a relatively simple solution, but I’m not sure what to search for. I am able to set the references after creating all the pages, but it feels very clunky to do so. Is there a way to do it while creating the objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:47:54+00:00Added an answer on June 18, 2026 at 10:47 am

    For what you’re trying to do, you’re going to need to use an Object Oriented approach in JavaScript. This will allow you to assign a reference to new instances of your object. For example this works:

    http://jsfiddle.net/Gq7vQ/

    function Action(url, name){
        this.url = url;
        this.prevAction = null;
        this.nextAction = null;
        this.name = name;
    }
    
    Action.prototype.doDisplay = function(){
        $(".label").html(this.name);
    }
    
    var actionOne = new Action('actionOneUrl.html', 'Action One');
    var actionTwo = new Action('actionTwoUrl.html', 'Action Two');
    
    actionOne.nextAction = actionTwo;
    actionTwo.prevAction = actionOne;
    
    console.log(actionOne.nextAction);
    

    EDIT: So the OP asked for an implementation that automatically sets up these links between newly added actions. So here is a doubly-linked list implementation:

    http://jsfiddle.net/wXC9B/1/

    function ActionList(){
        this.head = null;
        this.tail = null;
    }
    
    ActionList.prototype.doDisplay = function(index){
        var node = this.getNode(index);
    
        console.log(node.name);
    }
    
    ActionList.prototype.getNode = function(index){
        var current = this.head,
            c = 0;
    
        while(c < index && current !== null){
            current = current.nextAction;
            c++;
        }
    
        return current;
    }
    
    ActionList.prototype.add = function(url, name){
        var node = {
            url: url,
            name: name,
            nextAction: null,
            prevAction: null
        };
    
        if(this.head === null){
            this.head = node;
            this.tail = node;
        }
        else{
            this.tail.nextAction = node;
            node.prevAction = this.tail;
    
            //move tail to new node
            this.tail = node;
        }
    }
    
    var actionList = new ActionList();
    
    //Each add automatically sets up links between the two
    actionList.add('actionOneUrl.html', 'Action One');
    actionList.add('actionTwoUrl.html', 'Action Two');
    
    console.log(actionList.getNode(1));
    
    actionList.doDisplay(1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.