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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:59:57+00:00 2026-06-16T05:59:57+00:00

I have some ajax onclick stuff that updates this line when the value is

  • 0

I have some ajax onclick stuff that updates this line when the value is selected from the menu:

<li id="li_273" data-pricefield="special" data-pricevalue="0" >

The intention is to take the that value (data-pricevalue) and then multiple it by the amount that is entered from another input box. Here’s my function to try to make that happen:

$('#main_body').delegate('#element_240','keyup', function(e){

var temp = $(this).attr("id").split('_');
var element_id = temp[1];

var price = $('#li_273').data("pricevalue"); 

var ordered = $(this).val();

var price_value = price * ordered;

price_value = parseFloat(price_value);
if(isNaN(price_value)){
    price_value = 0;
}

$("#li_273").data("pricevalue",price_value);
calculate_total_payment();  

});

Except I get the following error:
Uncaught TypeError: Cannot call method ‘data’ of null

It appears as tho my attempt to get the price value out of getElementById isn’t correct. Any suggestions?

UPDATE: The code above has been edited from your suggestions and thanks to all. It appears to be working just fine now.

  • 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-16T05:59:58+00:00Added an answer on June 16, 2026 at 5:59 am

    This part is wrong:

    var price = document.getElementById('#li_273').data("pricevalue").val();
    

    Instead, you should use jQuery all the way here:

    var price = $('#li_273').data("pricevalue"); 
    

    Btw, you shouldn’t use .val() because .data() already returns a string. .val() is used exclusively for input elements such as <input> and <select> to name a few.

    Update

    Also, the rest of your code should be something like this:

    var price_value = parseFloat(price);
    if(isNaN(price_value)){
        price_value = 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some html returned from an ajax call that contains blocks of html.
I have some array data returned from an ajax call consisting of an image
I occasionally have some long running AJAX requests in my Wicket application. When this
I have some jquery code that is doing an ajax lookup and returning comma
I have some content that I am loading using jquery ajax. The content has
I have an image, onclick on which I make some ajax requests. I need
I have some tabs that load ajax content. When I click on the tabs
I have overriden the rowitem from my DefaultDataTable to add some onClick behavior. @Override
I have an html table that pulls data from a DB. It has an
I have a bit of ajax that runs onClick for check boxes of a

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.