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

  • Home
  • SEARCH
  • 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 6934805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:00:34+00:00 2026-05-27T12:00:34+00:00

I’m trying to create a scorecard program which allows the user to select cells

  • 0

I’m trying to create a scorecard program which allows the user to select cells of a table and gauge a score, I’m at a point where I can add each score the user clicks (admittedly in probably a very clunky way) but my problem is that the way the logic works is that only one value per row can be chosen. Here’s an example – http://jsfiddle.net/5q9nS/2/

To clarify, if the user chooses “#a1” the value of “2” should be added to the total. If the user then selects “#b1” this value should subtract the previously selected value because duplicate values from the same row are not allowed. However the total should add any value choosen from the rows a2-c2, a3-e3, a4-c4 etc…..

I hope that’s clear, the logic for the selected classes works to try and further demonstrate.

Any help would be hugely appreciated! As you will be able to tell i’m just on the learning curve and need to hit the summit.

HTML

<table width="100%" id="pcpScoring">
  <tr>
    <td width="30%">&nbsp;</td>
    <td width="14%" class="tblLabel">Own Savings</td>
    <td width="14%" class="tblLabel">Bank or B.S. Loan</td>
    <td width="14%" class="tblLabel">Dealer Finance</td>
    <td width="14%" align="center">&nbsp;</td>
    <td width="14%" align="center">&nbsp;</td>
  </tr>
  <tr valign="top">
    <td>How do you normally fund your vehicle?</td>
    <td class="tblNumber"><a id="a1">2</a></td>
    <td class="tblNumber"><a id="b1">4</a></td>
    <td class="tblNumber"><a id="c1">3</a></td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="tblLabel">1-2 years</td>
    <td class="tblLabel">3 years</td>
    <td class="tblLabel">4 years</td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
  </tr>
  <tr valign="top">
    <td>How often would you &quot;ideally&quot; like to change your vehicle?</td>
    <td class="tblNumber"><a id="a2">4</a></td>
    <td class="tblNumber"><a id="b2">2</a></td>
    <td class="tblNumber"><a id="c2">1</a></td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="tblLabel">upto 6,000</td>
    <td class="tblLabel">6-12,000</td>
    <td class="tblLabel">12-18,000</td>
    <td class="tblLabel">18-25,000</td>
    <td class="tblLabel">over 25,000</td>
  </tr>
  <tr valign="top">
    <td>How many miles do you drive per year?</td>
    <td class="tblNumber"><a id="a3">5</a></td>
    <td class="tblNumber"><a id="b3">4</a></td>
    <td class="tblNumber"><a id="c3">3</a></td>
    <td class="tblNumber"><a id="d3">2</a></td>
    <td class="tblNumber"><a id="e3">1</a></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="tblLabel">Part Exchange</td>
    <td class="tblLabel">Private Sale</td>
    <td class="tblLabel">Pass on to Famiy</td>
    <td class="tblLabel">&nbsp;</td>
    <td class="tblLabel">&nbsp;</td>
  </tr>
  <tr valign="top">
    <td>How do you usually dispose of your vehicle? </td>
    <td class="tblNumber"><a id="a4">4</a></td>
    <td class="tblNumber"><a id="b4">2</a></td>
    <td class="tblNumber"><a id="c4">1</a></td>
    <td align="center">&nbsp;</td>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="6" class="tblNumber" style="text-align:right"><span class="total">Total Score</span><span id="pcpScore" class="total">0</span></td>
  </tr>
</table>

jQuery

$(document).ready(function(){
//PCP Scorecard  on Click add class 
$('.tblNumber a').click(function() {
    $(this).addClass('selected');                             

});

$('#a1').click(function() {                 
$(this).addClass('selected');
  $('#b1, #c1').removeClass('selected');

addUp(parseInt($(this).text()));

});

$('#b1').click(function() {                 
$(this).addClass('selected');
  $('#a1, #c1').removeClass('selected');
    addUp(parseInt($(this).text()));
});

$('#c1').click(function() {                 
$(this).addClass('selected');
  $('#a1, #b1').removeClass('selected');
  addUp(parseInt($(this).text()));  
});

$('#a2').click(function() {                 
$(this).addClass('selected');
  $('#b2, #c2').removeClass('selected');
    addUp(parseInt($(this).text()));
});

$('#b2').click(function() {                 
$(this).addClass('selected');
  $('#a2, #c2').removeClass('selected');
    addUp(parseInt($(this).text()));
});

$('#c2').click(function() {                 
$(this).addClass('selected');
  $('#a2, #b2').removeClass('selected');
    addUp(parseInt($(this).text()));
});


$('#a3').click(function() {                 
$(this).addClass('selected');
  $('#b3, #c3, #d3,  #e3').removeClass('selected');
    addUp(parseInt($(this).text()));
});

$('#b3').click(function() {                 
$(this).addClass('selected');
  $('#a3, #c3, #d3,  #e3').removeClass('selected');
    addUp(parseInt($(this).text()));
});

$('#c3').click(function() {                 
$(this).addClass('selected');
  $('#a3, #b3, #d3,  #e3').removeClass('selected');
    addUp(parseInt($(this).text()));
});
$('#d3').click(function() {                 
$(this).addClass('selected');
  $('#a3, #c3, #e3,  #b3').removeClass('selected');
addUp(parseInt($(this).text()));
});

$('#e3').click(function() {                 
$(this).addClass('selected');
  $('#a3, #b3, #c3,  #d3').removeClass('selected');
addUp(parseInt($(this).text()));
});



$('#a4').click(function() {                 
$(this).addClass('selected');
  $('#b4, #c4').removeClass('selected');
addUp(parseInt($(this).text()));
});

$('#b4').click(function() {                 
$(this).addClass('selected');
  $('#a4, #c4').removeClass('selected');
addUp(parseInt($(this).text()));
});

$('#c4').click(function() {                 
$(this).addClass('selected');
  $('#a4, #b4').removeClass('selected');
addUp(parseInt($(this).text()));

});


    function addUp(addScore) {      


var totalScore  = (parseInt($('#pcpScore').text())) + addScore;    
            $('#pcpScore').html(totalScore);  

}


});
  • 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-27T12:00:35+00:00Added an answer on May 27, 2026 at 12:00 pm

    You can accomplish all you need within the click function:

    $('.tblNumber a').click(function() {
        $(this).parents('tr').find('a').removeClass('selected');
        $(this).addClass('selected');
        var total = 0;
        $('.tblNumber .selected').each(function() { 
            total += parseInt($(this).text());
        });
        $('#pcpScore').text(total);
    });
    

    Line by line it: Clears the previously selected items in the row, selects the current item, then iterates over the selected items in the table adding to the total then sets the text in the pcpScore span.

    EDIT: Working jsfiddle example: http://jsfiddle.net/cbailster/ycymB/

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.