Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const processReceipt = () =>{
- console.log("processing");
- const dublinPlane = 699.99;
- const dublinBoat = 999.99;
- const corkPlane = 599.99;
- const corkBoat = 799.99;
- const name = getCookieByName("Name");
- const transportation = getCookieByName("Transportation Choice");
- const city = getCookieByName("City Choice");
- console.log(name);
- console.log(transportation);
- console.log(city);
- $("[name='name']").val(name);
- $("[name='city']").val(city);
- $("[name='transportation']").val(transportation);
- console.log(dublinPlane.toFixed(2))
- if( city === "none" || transportation === "none"){
- $("#total-due").val("$0 (Requires City AND Transportation)")
- } else if( city === "Dublin" && transportation === "Plane"){
- $("#total-due").val(dublinPlane.toFixed(2));
- }else if( city === "Dublin" && transportation === "Boat"){
- $("#total-due").val(dublinBoat.toFixed(2));
- }else if( city === "Cork" && transportation === "Plane"){
- $("#total-due").val(corkPlane.toFixed(2));
- }else if( city === "Cork" && transportation === "Boat"){
- $("#total-due").val(corkBoat.toFixed(2));
- }
- }
- const getCookieByName = (name) =>{
- const cookies = document.cookie;
- let start = cookies.indexOf(name + "=");
- if (start === -1){
- return "";
- }else {
- start = start + (name.length +1);
- let end = cookies.indexOf(";", start);
- if (end === -1){
- end = cookies.length;
- }
- const cookieValue = cookies.substring(start,end);
- return decodeURIComponent(cookieValue);
- }
- }
- $(document).ready(
- () => {
- processReceipt();
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement