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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:26:24+00:00 2026-05-24T17:26:24+00:00

I have this code: <div id=star-rating> <script type=text/javascript> $(function(){ $(‘#star-rating form’).submit(function(){ $(‘.test’,this).html(”); $(‘input’,this).each(function(){ if(this.checked)

  • 0

I have this code:

<div id="star-rating">
<script type="text/javascript">
$(function(){
  $('#star-rating form').submit(function(){
  $('.test',this).html('');
   $('input',this).each(function(){
   if(this.checked) 
  //$('.test',this.form).append(''+this.name+': '+this.value+'<br/>');
$('.test',this.form).append(this.value);
});
 return false;
});
});
</script>

<form name="form1" method="post" action="<?=base_url();?>rate/student">
    <div class="dbtable">

    <table cellpadding="0" cellspacing="0" border="0"><tbody>
    <th colspan="4" align="left">Personal Appearance</th>
    <tr><td width="10px"></td><td width="60%">Neatness</td>
        <td width="20%">
            <input name="neat" type="radio" class="neat-star" value="1" title="Poor"/>
            <input name="neat" type="radio" class="neat-star" value="2" title="Fair"/>
        </td>
        </tr>

    <tr><td></td><td>Health</td>
        <td>
            <input name="health" type="radio" class="health-star" value="1" title="Poor"/>
            <input name="health" type="radio" class="health-star" value="2" title="Fair"/>
        </td>
        </tr>
    <tr><td></td><td align="right"></td>
        <td><input type="submit" value="Submit scores!" /></td>
        <td><div class="test Smaller">
            <span style="color:#FF0000">Results</span>
            </div>
        </td></tr>

So now I have 2 radio star rating. What I want is when I click the submit score it will add up the 2 selected radio box. E.g when click radio button neat with the value of 1 and radio button health with the value of 2 then the result will show 3 coz 1+2=3 in my div class=test. Could anyone help me with this.

  • 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-24T17:26:26+00:00Added an answer on May 24, 2026 at 5:26 pm
    $('#star-rating form').submit(function() {
        $('.test', this).html('');
        var total = 0;
        $('input', this).each(function(){
            if(this.checked) {
                total += parseInt(this.value, 10);
            }
        }
        //Do something with total
        return false;
    });
    

    You need to use parseInt to convert a String into a Number. Otherwise, you’ll just be concatenating values onto a string.

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

Sidebar

Related Questions

I have this code: <div class=small_map_wrapper> <script type=text/javascript>loadMap('44.7958873,20.471077899999954');</script> I will fetch this content with:
I have a code here: <script type=text/javascript src=<?=base_url()?>lib/jquery-1.6.2.min.js></script> <script type=text/javascript> $('.hover-star').click(function (){ $('.someDiv').text(this.val()); })
I have this code: <div> <input id=number type=text /> <select id=Selection name=D1> <option>Plus 1</option>
When I put this code outside of the <table> ...it will work. <script type=text/javascript>
So I have this code: jQuery('div[class=someClass] :input:not(:button)').each(function() { if (input type is drop-down) {
I have this code in my jsp <div class=controls> <input type=image class=sprite submit-button button
I have this code $('div#create_result').text(XMLHttpRequest.responseText); where the content of XMLHttpRequest is responseText: Content-Type: application/json;
I have this code : #bottom-div { z-index:999 } <input type=text id=main /> <div
I have this code : <div class=areaButton> <input type=submit value=Add> </div> .areaButton { float:left;
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid

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.