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

Home Forums JavaScript Update price onchange via jQuery Reply To: Update price onchange via jQuery


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.