Based on my 1 or 2 days understanding of basics of JQuery I have written a small code just to fetch the vale of what is selected, but I could not publish(in alert box) that →
So there are two things wrong with the current version: #1: You fixed it in the wrong direction. Make your selector the class one, you cant have two elements with the same ID. #2: Your codepen doesnt have jquery loaded.
Thanks. code doesn’t have any issues, but silly mistakes. I will remember to load JQuery in codepen in future for sure.
Alert: we use is to check if the code is working. Can you please guide me what should I do next. I believe some math and some conditions are needed now to generate output which may require adding more than one prices selected.
I believe that something like this will be the solution →
$(document).ready(function() {
$(".myactivity").click(function(event) {
var total = 0;
//some code here to do mathematical calculations
if (total == 0) {
$('#finalprice').val('');
} else {
$('#finalprice').val(total);
}
});
});
But this code → //some code here to do mathematical calculations
should have some mathematical code - I am missing that link.