-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
143 lines (84 loc) · 2.46 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
$(function(){
$(".form-group").hide().filter("#seat").show();
//hover to fade button
var $seat = $("button.button");
$seat.mouseenter(function(){
$(this).fadeTo("fast", 0.5);
});
$seat.mouseleave (function(){
$(this).fadeTo("fast", 1);
});
//click to toggle the blue class
$seat.click(function(){
$(this).toggleClass("blue");
//$(this).unbind("onmouseover").unbind("onmouseout");
});
var arraySeats =[];
$(".button").on('click',function() {
var text = $(this).text();
$("#input").val(text);
//Puts seats into an array and prints them in the input
if (text !== "reserved"){
arraySeats.push(text);
console.log(arraySeats);
arraySeats.forEach(function(each){
$("#input").val(arraySeats);
})
}
})
//******Adds input once previous input is filled******
$( "#name" ).keypress(function() {
$("#email").show();
});
$( "#email" ).keypress(function() {
$("#date").show();
});
$( "#email" ).keypress(function() {
$("#submit").show();
});
//******Check that fields are filled in to submit******
$(".btn").click(function(){
var $name = $("input#enterName");
var $email = $("input#enterEmail");
var $date = $("input#selectDate");
var $allSeats = $("input#input");
if(!$name.val())
//&& !$email.val() && !$date.val() && !$allSeats.val()
{
$("ul.textbox").append('<li>' + "Fill out all fields" + '</li>');
}
else if(!$email.val()){
$("ul.textbox").append('<li>' + "Fill out all fields" + '</li>');
}
else if(!$date.val()){
$("ul.textbox").append('<li>' + "Fill out all fields" + '</li>');
}
else if(!$allSeats.val()){
$("ul.textbox").append('<li>' + "Fill out all fields" + '</li>');
}
else{
$name = $name.val();
$email = $email.val();
$date = $date.val();
$allSeats = $allSeats.val();
console.log($name);
//$(".textbox").append("<li>" +$name + "</li>" + "<li>" + $email + "</li>" +"<li>" $date + "</li>" + $allSeats +"</li>");
$("ul.textbox").append('<li>' + $name + '</li>');
$("ul.textbox").append('<li>' + $email + '</li>');
$("ul.textbox").append('<li>' + $date + '</li>');
$("ul.textbox").append('<li>' + $allSeats + '</li>');
// $(".textbox").val($email);
// $(".textbox").val($date);
// $(".textbox").val($allSeats);
}
});
$("button").on("click", function() {
var el = $(this);
if (el.text() === el.data("text-swap")) {
el.text(el.data("text-original"));
} else {
el.data("text-original", el.text());
el.text(el.data("text-swap"));
}
});
});