Hi I have this JavaScript function:
function calcscore(){
var score = 0;
$(".calc:checked").each(function(){
score+=parseInt($(this).val(),10);
});
$("#price").text(score);
}
$().ready(function(){
$(".calc").change(function(){
calcscore()
});
});
Now i want to call this calcscore() fucntion on views.py in Django. Say i have this function on my Views.py
def get_total():
try:
final_cost =0
final_cost = calcscore()
except:
dummy_cost
return final_cost
Should i use ajax? or how can i achieve this?