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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:27:08+00:00 2026-05-19T00:27:08+00:00

I am getting NaN error while clicking radio button first. The page have a3

  • 0

I am getting NaN error while clicking radio button first. The page have a3 radio button when I click that 1st button it saya NaN and remaining 2 buttons has no response

this is my HTML

<input type="hidden" name="totalamount" id="totalamount" value="<?php echo get_total_amount();?>" /

<input type="radio" name="rmr"  id="payment1" value="3" onclick="updatepayment(this.value)" />
<input type="radio" name="rmr"  id="payment2" value="5.5" onclick="updatepayment(this.value)" />
<input type="radio" name="rmr"  id="payment4" value="10" onclick="updatepayment(this.value)" />
<div id="finalamount">
</div>

also I have mentioned my JS

$(document).ready(function(){  
    $('input[name=rmr]').click(function () {  
        //make sure one is checked    
        if($('input[name=rmr]:checked').length > 0) {    
            $('#finalamount').html($("#totalamount").val() * $("input[name=rmr]:checked").val());    
        } 
    }); 
}); 
  • 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-19T00:27:08+00:00Added an answer on May 19, 2026 at 12:27 am

    Three things:

    1) As you’re using the amount from the “totalamount” element, one has to ask: Are you sure that

    value="<?php echo get_total_amount();?>"
    

    …is outputting a valid number? Because if not, then the code

    $('#finalamount').html($("#totalamount").val() * $("input[name=rmr]:checked").val());
    

    …will indeed result in NaN. The * operator will try to convert both of its operands from strings to numbers, and of course if the value output by that PHP code isn’t a valid number (for instance, if it’s “$0.00” or something), the result of the conversion will be NaN. And NaN times anything is NaN.

    This example of an invalid amount in the “totalamount” element yields something that looks a lot like the behavior you describe. (That code isn’t identical to yours, I did some very light refactoring, see below. But for the purposes of demoing an invalid number, it doesn’t matter.)

    2) There’s no > at the end of that hidden input in the text of your question. If you did a direct copy-and-paste, I wonder if that could be the problem?

    3) As you’re using jQuery, there’s no need for the onclick attributes. Instead:

    $(document).ready(function(){  
       $("input[name=rmr]").click(function(){
            var checked = $("input[name=rmr]:checked");
            updatePayment(this.value);
            if (checked.length > 0) { // make sure one is checked
            {    
                $("#finalamount").html( $("#totalamount").val() * checked.val() );    
            } 
        }); 
    }); 
    

    …assuming you want updatePayment called every time.

    Live example

    Folding updatePayment into the main click behavior lets you avoid any issues that may exist with the order in which DOM0 (onclick attribute) handlers and DOM2 handlers (the ones used with jQuery) are called.

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

Sidebar

Related Questions

I'm getting an error here that says I haven't defined a method, but it
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the
I getting the following error when I try to connect to my server app
Im getting frustrated because of OpenDNS and other services (ie: roadrunner) that now always
Im getting a string (simplified) from the backend that should be : { menu:
Anyone getting this error when using the new free chart controls MS bought from
I'm getting a weird error where in Internet Explorer 7, when I call Math.round
I have an XML file that has a number of nodes, each of which
i know, this is a realy popular error. But my problem is that my
Getting this after solving a Error converting data type nvarchar to datetime error. Using

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.