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 6704047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:14:37+00:00 2026-05-26T07:14:37+00:00

I am trying to access data from a javascript object in order to dynamically

  • 0

I am trying to access data from a javascript object in order to dynamically populate a div with the appropriate info. In my example, there are three steps in a tutorial. When the user is finished with each step, they click the button to go on to the next step. I’d like the function “getStepData(stepNumber)” to be called onclick, and for the step number to be passed into the function and used in the html I am building in the javascript. The sample code is here, but I also have it half working in jsFiddle:

http://jsfiddle.net/enajenkins/xvFeX/24/

//create data object that will hold all data to be accessed later.               
var tutorialDataObj = {    
//define the tutorial container
profilePageTutorials: {        
    //define the steps and their data
    step1: {
        id: "tip1",
        class: "profile_tip",
        title: "Step 1",
        subtitle: "How to edit your profile"
    },//END: step1        
    step2: {
        id: "tip2",
        class: "search_tip",
        title: "Step 2",
        subtitle: "How to search"
    },//END: step2        
    step3: {
        id: "tip3",
        class: "change-photo_tip",
        title: "Step 3",
        subtitle: "How to upload a new photo"
    }//END: step3                
}//END: profileTutorial    
}//END: tutorialDataObj
//identify the div container that the dynamic html will be written into
var tutorialWindow = document.getElementById("tutorial-step-window");
//shorten the path to the data in the object
var tutorials = tutorialDataObj.profilePageTutorials;
//loop through each step in the data object
for ( var step in tutorials ) {
    //build the html to be inserted dynamically using data from object
    var html = ["<h2 id='title'>" + tutorials.step1.title + "</h2>" +
                "<h3>" + tutorials.step1.subtitle + "</h3>"];
    //insert the html into the div container
    tutorialWindow.innerHTML = html;
    alert(tutorials[step].subtitle);
}

function getStepData (stepNumber) {
alert(stepNumber); //here, I'm trying to access the argument from the input button.     I'd like to pass it into the html I'm building above so I can access the data from the intended step when the user clicks the button.
}

and here is the html:

<div id="tutorial-step-window" class="tip">HOWDY</div>
<input type="button" value="Change Data" onclick="getStepData(3)" />
  • 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-05-26T07:14:37+00:00Added an answer on May 26, 2026 at 7:14 am

    Try this..

    http://jsfiddle.net/xvFeX/45/

    I go about it a slightly different way then you describe but accomplish the same goal:

    I remove the inline click event on the button and added an id.
    then I added the click in the js and also did a count in there based on the number of steps in the object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to transfer some data from Access to SQL Server 2000 (there are
I am trying to access information from an Oracle meta-data table from within a
I'm trying to pull in data from a remote SQL Server. I can access
I'm trying to call a Flash function from javascript passing complex data types as
I am trying to access certain pieces of data from an xml file, here
I'm trying to use JQuery's $.getJSON to access Model data from the Controller, and
I am trying to access the data from MS Access Database using C#. in
everyone. I'm trying to get data from some page, it's updated using javascript. First,
I am trying to populate a Postcode (ie zipcode) input field with data from
I'm trying to access list data using SSRS 2008. I have created an XML

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.