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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:29:16+00:00 2026-05-13T17:29:16+00:00

So I was offered help with this on another question, but I’m struggling to

  • 0

So I was offered help with this on another question, but I’m struggling to implement it when my app progresses in complexity…

var gender;
var age;
$("#gender :radio").click(function() {
  gender = $(this).val();
  update();
});
$("#age li").click(function() {
  age = $(this).text();
  $('#children').show();
  update();
});


function update() {
  var text = gender || "";
  if (text.length > 0) {
    text += " -> ";
  }
  text += age || "";
  $("span.jquery_out").text(text);
}

Which is fine, but I’m wanting to add in 12 variables, and I need to have the update() function clock up in a more desirable way.

My vars are:

var gender;
var age;
var children;
var income;
var stage2select;
var day;
var spend;
var categories;
var product;
var price;
var quantity;
var total;

How would I get these to cycle through the update() function with ” -> ” in-between each one, without over using code?

Thanks, Matt.

  • 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-13T17:29:17+00:00Added an answer on May 13, 2026 at 5:29 pm

    You could change your long variable list to an object and then loop the object like this:

    var myObj = {
        gender:'',
        age:'',
        children:'',
        income:'',
        stage2select:'',
        day:'',
        spend:'',
        categories:'',
        product:'',
        price:'',
        quantity:'',
        total:''
    };
    
    $("#gender :radio").click(function() {
        myObj.gender = $(this).val();
        update();
    });
    
    $("#age li").click(function() {
        myObj.age = $(this).text();
        $('#children').show();
        update();
    });
    
    function update() {
        var text = "";
        $.each(myObj, function(i){
            if (this != ''){
                if (text.length){
                    text += " -> ";
                }
                text += this;
            }
        });
        $("span.jquery_out").text(text);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, stuck on another Python Question. I have tried this a few times, but
In another question, other users offered some help if I could supply the array
Is there a workaround for Internet Explorer to implement the functionality offered by 'this'
I dont understand DatePeriod, DateInterval classes very well. This question is linked to another
This is probably going to end up as a stupid question, but countless research
This is a rather specific question but I am trying to use querySelectorAll for
In the examples offered by the official site http://www.jacklmoore.com/colorbox/example2/ This website http://threadless.com opens in
I have searched here on SO and tried different solutions offered here, but cannot
I appreciate any help that can be offered on the subject. At the end
This question has been answered. The problem was that myEventMoveTrainManaul() was being called from

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.