Hello all,
I am currently working on a website from scratch so you can place a order online for example like ordering a pizza online from dominoes or some other restaurant or food place but I am doing it for this special restaurant.
Right now I am setting up the online ordering of a sub.
I have it so if you select bread then you should select a filling so your sub sandwich isn’t plain. I have a label working so it pops up when the order button is clicked. I believe I would want it so the button would be disabled if the fields are incorrect? I am widely open to any suggestions or ideas in which you believe I could improve my site.
The next part I am working on is that you need to order a sandwich before 10 am of the current day otherwise it will display a message saying you will not be able to receive that sandwich of the current day until the next day. I plan on bringing up a cancel option window in case the user doesn’t want the sub for next day so they can cancel their order. I am not sure how exactly I should do this part yet.
Right now I just have a date object that is receiving the exact current time and I will compare it with another date object of 10am of that current day and do some if and else statements to decide what to do.
Again I am widely open to any ideas or suggestions for other possibilities.
<div>
<h4>1). Select Bread</h4>
<select id="selectBread">
</select>
<!--
<h4>2). Select Spread</h4>
<select id="selectSpread">
</select>
<div id="spreadValid" style="color:red; font-weight:bold; display:inline;"></div>
<!--
<h4>3). Extra Spreads(+$0.80)</h4>
<select id="selectExtraSpread">
</select>
<div id="extraSpreadValid" style="color:red; font-weight:bold; display:inline;"></div>
</div>
<!--
<form method="post" id="selectFillings">
<fieldset id="fillings">
<legend><h4>4). Choose up to two fillings (Extra + $1.20)</h4></legend>
<div id="fillingValid" style="color:red; font-weight:bold; display:inline;"></div>
</fieldset>
</form>
<button id="addToOrder" type="button">Add to order</button>
function getBread() {
var deferred = new $.Deferred();
deferred.resolve([
{ value: 'Wheat', text: 'Wheat' },
{ value: 'Rye', text: 'Rye' },
{ value: 'French', text: 'French' },
{ value: 'Wrap', text: 'Wrap' }
]);
return(deferred);
}
function initializeSelect(elementName, dataService) {
var $element = $(elementName);
$.when(dataService()).then(function(data) {
$('<option value=""></option>').appendTo($element);
for(var itemIndex in data) {
$('<option value="'+data[itemIndex].value+'">'+data[itemIndex].text+'</option>').appendTo($element);
}
});
}
if (validateOrderandLunchbag(fillingCount)) {
AddLunchBagToMyOrder(lunchBag);
}
function validateOrderandLunchbag(numberOfFillings)
{
var isValid = true;
var $addToOrder = $('#addToOrder');
var breadValue = $('#selectBread').val();
var spreadValue = $('#selectSpread').val();
if (breadValue != "" && spreadValue == "") {
var message = "You are allowed to select a spread, If you want.";
document.getElementById("spreadValid").innerHTML = message;
document.getElementById("spreadValidbtn").innerHTML = message;
} else {
document.getElementById("spreadValid").innerHTML = "";
document.getElementById("spreadValidbtn").innerHTML = "";
}
if (breadValue != "" && numberOfFillings == 0) {
var fillingMessage = "You should want something on your sub so it isn't plain.";
document.getElementById("fillingValid").innerHTML = fillingMessage;
document.getElementById("fillingValidbtn").innerHTML = fillingMessage;
isValid = false;
} else {
document.getElementById("fillingValid").innerHTML = "";
document.getElementById("fillingValidbtn").innerHTML = "";
}
return isValid;
}
function determineCutoffTime() {
console.log("cut off time function");
var msg = "To recieve an order the current day it must be played before 10 a.m. of that day.";
var jsDate = new Date();
var jsTime = jsDate.getHours() + ":" + jsDate.getMinutes() + ":" + jsDate.getSeconds();
console.log(jsTime);
}