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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:03:50+00:00 2026-06-15T23:03:50+00:00

I am building a web app that basically consists of several selects, couple of

  • 0

I am building a web app that basically consists of several selects, couple of checkboxes, and one input text field. Each select contains more than 4 options. After a user selects their options, fills out the text input, checks off any possible checkboxes, and presses Submit, a template text is generated in a textarea. The generated text is basically a template that uses all of the options specified by the user. In a simple form, it could go something like this:

  1. User selects “blue” and “hello” from selects, does not check any checkboxes, and writes “John” in the input text field.
  2. The text that is then generated is:

Hello, John, you have a blue car.

Now, the above example is about 100 times less complex than what my generated text is actually like. And here comes the question: what is the best way to code this? Currently, I opted for the ugly nested switch statements with a lot of static text and loads of IF statements. There is a limit to it though because if I add more complexity, I’m hitting the limit of extending the current switch statements and also wanting to avoid creating another level of switch statements.

Is the best way to just generate all possible variation of the text (I’m guessing there is at least a 200-250 and simply run through a single switch statement that return a selected template (this however makes applying changes to one word/sentence/etc. a nightmare)? Or should I abstract all the choices and build the final text with just variables (e.g. using above example: $greeting, $name, $middle $color $object.)? What are the best practices for generating text?

This is not specific to JavaScript but that is what I’m using so suggestions for how to do it in JS would be welcome. Thanks for your help!

  • 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-15T23:03:52+00:00Added an answer on June 15, 2026 at 11:03 pm

    One way to do this is to have a data model using JSON. Your UI updates the values in the data model, then you output the whole thing after every change. This way you can skip a lot of the logic.

    jQuery templating can help make this work:

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

Sidebar

Related Questions

Basically I have a web app that I'm building on top of an existing
I'm building a MVC web app that consist of 3 projects. One for the
I'm currently building a web-app that has one section where the user sees a
I am building a web app that allows our field staff to create appointments.
I'm building a web app that uses ajax to communicate with the server. Basically,
I am building a web app that takes several tiff image files and merges
I'm building a web app that processes the text in a web page, adds
Let's say I am building an web app that is connecting and basically parsing
I'm building a web app that's going to support multiple languages. For the moment,
I'm building a web app that integrates with Google Drive, and am wondering if

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.