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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:06:12+00:00 2026-05-27T19:06:12+00:00

Imagine the user gets a better discount the higher the data-hipsterness value is and

  • 0

Imagine the user gets a better discount the higher the data-hipsterness value is and we get this value by asking 4 questions and providing 4 choices for each question. I’m sure it’s most basic stuff yet…I need to keep track of a variable every time the user choose one of the options and update it’s value so that at the end of the “test” I can do different ifs statements with that result.
What I got so far is a demo http://lab.polmoneys.com/nohints.html and this code :

EDIT http://jsfiddle.net/polmoneys/s4xLF/4/

$('h3').click(function(event) {

var value = $(this).data("hipsterness");    
var context =$(this).parent(".cpu");
var counter =$("#counter").text();
var newValue=  counter + value;

$("#counter").text("" + value);
$("#total").val(newValue);

    context.fadeOut("slow", function(e){ 
        context.next(".cpu").fadeIn();

        });
});

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-05-27T19:06:12+00:00Added an answer on May 27, 2026 at 7:06 pm

    The problem, as I think Gaby was eluding to, is that you’re concatenating strings, not adding numbers. However, you will need to set an initial value on the total input text field that is numeric to get it to work. Alternatively, could do a null coalesce to set it to 0 if it can’t find a numeric value as NaN will be ‘falsey’. This should work for you:

    $('h3').click(function(event) {
    
      var value = $(this).data("hipsterness");    
      var context = $(this).parent(".cpu");
      var counter = parseInt($("#total").val(), 10) || 0;
      var newValue= counter + value;
    
      $("#counter").text("" + value);
      $("#total").val(newValue);
    
      context.fadeOut("slow", function(e){ 
        context.next(".cpu").fadeIn();
      });
    });
    

    On an unrelated note, you’re going to want to make your input field readonly, or people will be able to freely type whatever value they like in the field, and make sure your cart information isn’t easily visible by clicking view source (because then I could easily just open a console and change the price on whatever I want).

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

Sidebar

Related Questions

Imagine an in-house application aimed at the very technical user. The app maintains data.
I imagine this has a rather simple answer <% for user in @users %>
Imagine a user that would like to put a form on their website that
I have a newbie WPF question. Imagine my user control has a namespace declaration
Imagine an ASP.NET website which displays stock prices when a user logs in. Can
Imagine I have an existing process running under windows as a particular user. Would
Imagine we have two tables in the database, user (FK id_role) and role (PK
Imagine that HTML page is a game surface (see picture). User can have n
Let's imagine I have a database and I want to programatically allow the user
Sorry for asking another time help on this matter, but all others posts didn't

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.