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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:23:44+00:00 2026-06-18T16:23:44+00:00

I’ve tried to look for a similar question and either can’t phrase it properly

  • 0

I’ve tried to look for a similar question and either can’t phrase it properly or I’m being rather silly. I’m relatively new to JavaScript, and have a question about creating multiple object instances:

Here it is:

Say you’re trying to build a ‘list builder’ dynamically with javascript. You create multiple lists and add items to them. So you build a class like so (note, the code is mostly illustrative to try and clarify the question):

var dynamicList = function(listName){
    this.listTitle = listName;
}

dynamicList.prototype = {

    buildList : function(){
        var template = $('<ul id="'+ this.listTitle +'"></ul>').append('<h2>' + this.listTitle + '</h2>';
        $(body).append(template);
    }

}

now here comes the question:

Say I use an input form to create the list wrapper, and each time they submit the form, a new list is born. How is this managed? What I would presume would need to happen would be creating a new object each time:

var list1 = new dynamicList("[user input title from form]"); //first list
list1.buildList();

var list2 = new dynamicList("[user input title from form]"); //second list
list2.buildList();

var list3 = new dynamicList("[user input title from form]"); //third list
list3.buildList();    

var list[n] ... // and so on
list[n].buildList();

But I can’t figure out how to do this. Can I dynamically create variable names, or how would one approach this problem? Would you wrap it in a higher level object and create an increment system for each list created? Is this even a problem, or could you just recursively use var list = new dynamicList for each form?

I hope I have framed my issue in a way that everyone can understand, thanks for taking the time to read through it. I’d also appreciate any suggestions as to how to structure the code to ensure utmost scalability.

Thanks!

  • 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-18T16:23:45+00:00Added an answer on June 18, 2026 at 4:23 pm

    If you want to have n of something and be able to reference them – put them into an array.

    var myLists = []; //Shorthand for new Array()
    
    var list = new DynamicList("[user input title from form]"); //first list
    list.buildList()
    myLists.push(list);
    
    list = new DynamicList("[user input title from form]"); //second list
    list.buildList()
    myLists.push(list);
    

    You could also get rid of the buildList() call by creating a constructor.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
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
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.