im kinda working on making my own website but in just giving some functions im already struggling...this website is an online food ordering.i need to get the sum of foods...but i cannot make the values come out of the functions even i use return... someone help me with this? im not that good at javascript yet i just studied 2days ago
here is my current work...
$('#jollyoption').click(function(totalchicken){
var e = document.getElementById("jollyoption");
var chicken = e.options[e.selectedIndex].value;
var totalchicken = chicken;
chicken = parseInt(chicken);
document.getElementById("demo").innerHTML = totalchicken;
return totalchicken;
});
$('#jollyoption1').click(function(totalburger){
var a = document.getElementById("jollyoption1");
var burger = a.options[a.selectedIndex].value;
var totalburger = burger;
burger = parseInt(burger);
document.getElementById("demo1").innerHTML = totalburger;
return totalburger;
});
$('#jollyoption2').click(function(totalfries){
var a = document.getElementById("jollyoption2");
var fries = a.options[a.selectedIndex].value;
var totalfries = fries;
fries = parseInt(fries);
document.getElementById("demo2").innerHTML = totalfries;
return totalfries;
});
var total =totalfries+totalburger+totalchicken;
document.getElementById("demo3").innerHTML = total;
if you have time to run it... everytime i place the quantity of orders of the 1 one the 4 restaurants (choose the jollibee PS:not editing other resto yet) i get that NaN because i cannot get the variables and their values back at the main body so i could just add the total and just print them out.can someone help me with this problem? thankyou in advance
$at the very start, for$(document).ready(main()).