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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:09:08+00:00 2026-06-01T16:09:08+00:00

I have a simple form which works as intended. It is a multi-step form

  • 0

I have a simple form which works as intended. It is a multi-step form that only shows one question at a time. When the user clicks on an input field (all radio buttons) they get taken to the next question, which is different depending on what they clicked and then finally they get a submit button after the last question.
I currently have several .click functions, and this works well. However, I am sure it is not the most efficient way to do this, in terms of both writing and performance. Is there a more efficient way to use multiple .click functions?

$('.male').click(function() {
  $('#male').show();
  $('#gender').hide();
});

$('.female').click(function() {
  $('#female').show();
  $('#gender').hide();
});
  • 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-01T16:09:10+00:00Added an answer on June 1, 2026 at 4:09 pm

    You could give all of the questions the class of ‘question’ and then each answer could have an id corresponding to a class (or other) property of the upcoming branch you wanted to display.

    Therefore each response would hold the name for what to display next for you and you would be able to only have one click handler.

    I.e.:

    $("input").click(function() {
        $(".question").hide();
        var itemToShow = $(this).attr("id");
        //alert(itemToShow);
        if ($("."+itemToShow).length > 0) {
            $("."+itemToShow).show("normal");
        } else {
            $(".finale").show("normal");
        }
    });
    

    You’ll probably need to play around with it a little bit until the control works as you’d like. Here’s a fiddle to work off of.

    Update: Here’s the latest fiddle demonstration.

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

Sidebar

Related Questions

Using Rails 3.0.7. I have a simple form which shows all records from one
I have simple form like this which accepts only two values string action and
I have a relatively simple form which asks a variety of questions. One of
I have written a simple CRUD form which has one select list. However the
I have a script that performs some simple editing which works fine, the problem
I have a very simple PHP form, which shows a checkbox, and will store
I have a simple modal form which I'd like to close when Esc is
I have a simple Ruby on Rails form which includes an authenticity_token. Unfortunatly, I
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
I have an ajax form in asp.net mvc which is as simple as this:

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.