The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Update price onchange via jQuery

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #176728

    Hello everyone,

    I’m trying to update a price column in my HTML table via a select option with onchange using jQuery, but i’m not having much luck, the function name I’m using is called “updatePrice”, you can view my code here:

    I was trying .parent, then I gave .closest a try without much luck, if you could point me in the right direction that would be great, thanks :)


    updatePrice does not know what $(this) is. If you log it to the console, you will see that it in the context of that function, this refers to the window object. You have named the param e, which is misleading because it’s not an event, it’s the actual select element. So to make it work, you could do:

    function updatePrice(select) {

    So you are turning a list into a table using JS. I assume you can’t just have the table being served in the markup to begin with? If you really really need to create it like that, I think I would build the table using jQuery objects from the start and then register event handlers on them using jQuery, not the onchange attribute, that’s weird IMO. replaceWith can take jQuery as a parameter, so it should be fine.


    Awesome, thank you so much!

    Yes the ideal solution would of been to do it in ether HTML or in jQuery, the idea that I’m working on is converting un/organized lists in to a functioning pricing table, i.e. making it really simple for a user to add a list and not having to worry about knowing any HTML, CSS, or Javascript.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.