-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular11cascadingassignment.html
240 lines (205 loc) · 8.96 KB
/
angular11cascadingassignment.html
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!-- Display cascading drop down load in online movie ticket system -->
<html lang="en">
<head>
<title>Drop Down Assignment</title>
<script src="vendors/angular.js"></script>
<style>
body{
background-color: ghostwhite;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif
}
caption{
color:green;
font-size: 20px;
}
</style>
<script>
var app = angular.module("MyApp",[]) ;
app.controller("MyController",function($scope){
$scope.citySelected = "";
$scope.cinemaOptions = [] ;
$scope.cinemaSelected = "";
$scope.movieOptions = [];
$scope.movieSelected = "";
$scope.showTiming= [];
$scope.seatSelected= "";
$scope.moviePic="" ;
$scope.totalSeats="";
$scope.showTimeSelected="";
$scope.ticketPrice="";
$scope.isHide="";
$scope.getMovieDetails = function(){
switch($scope.movieName){
case "X-man":
$scope.moviePic = $scope.movieInfo[0].poster;
break;
case "Ant-man":
$scope.moviePic = $scope.movieInfo[1].poster;
break;
case "Nirahua Patna wala":
$scope.moviePic = $scope.movieInfo[2].poster;
break;
case "Despicable Me 2":
$scope.moviePic = $scope.movieInfo[3].poster;
break;
}
};
$scope.movieInfo = [
{Name:"X-man",poster:"img/xman.jpg"},
{Name:"Ant-Man",poster:"img/antman.jpg"},
{Name:"Nirahua Patna wala",poster:"img/nirahua.jpg"},
{Name:"Despicable Me 2",poster:"img/dm2.jpg"},
]
$scope.cities = ['Delhi','Patna'] ;
$scope.delhiCinema = ['Karol Bag','Rajeev Chawok'];
$scope.patnaCinema = ['RajendraNagar','GandhiMaidan'];
$scope.karolBagMovies = ['X-man','Ant-man'];
$scope.rajeevChawokMovies = ['Ant-man','Despicable Me 2'];
$scope.rajendraNagarMovies = ['Ant-man','X-man'];
$scope.gandhiMaidanMovies = ['Ant-man','Nirahua Patna wala'];
$scope.showTiming1 = ["09:00 am","12:00pm","04.00pm"]
$scope.showTiming2 = ["11:00 am","2:00pm","06.00pm"]
$scope.showTiming3 = ["08:30 am","4:00pm","09.00pm"]
$scope.setCity = function(){
$scope.isHide=true;
switch($scope.citySelected){
case "Delhi":
$scope.cinemaOptions = $scope.delhiCinema ;
break;
case "Patna":
$scope.cinemaOptions = $scope.patnaCinema ;
break;
}
}
$scope.setCinema = function(){
$scope.isHide=true;
switch($scope.cinemaSelected){
case "Karol Bag":
$scope.movieOptions = $scope.karolBagMovies ;
break;
case "Rajeev Chawok":
$scope.movieOptions = $scope.rajeevChawokMovies ;
break;
case "RajendraNagar":
$scope.movieOptions = $scope.rajendraNagarMovies ;
break;
case "GandhiMaidan":
$scope.movieOptions = $scope.gandhiMaidanMovies ;
break;
}
}
$scope.setMovie = function(){
$scope.isHide=true;
if($scope.movieSelected==="X-man" && $scope.cinemaSelected==="Karol Bag"){
$scope.showTiming = $scope.showTiming1 ;
}else if($scope.movieSelected==="Ant-man" && $scope.cinemaSelected=="Karol Bag"){
$scope.showTiming = $scope.showTiming3 ;
}else if($scope.movieSelected==="Ant-man" && $scope.cinemaSelected=="Rajeev Chawok"){
$scope.showTiming = $scope.showTiming2 ;
}else if($scope.movieSelected==="Despicable Me 2" && $scope.cinemaSelected=="Rajeev Chawok"){
$scope.showTiming = $scope.showTiming1 ;
}else if($scope.movieSelected==="Ant-man" && $scope.cinemaSelected=="RajendraNagar"){
$scope.showTiming = $scope.showTiming3 ;
}else if($scope.movieSelected==="X-man" && $scope.cinemaSelected=="RajendraNagar"){
$scope.showTiming = $scope.showTiming1 ;
}else if($scope.movieSelected==="Nirahua Patna wala" && $scope.cinemaSelected=="GandhiMaidan"){
$scope.showTiming = $scope.showTiming3 ;
}else if($scope.movieSelected==="Ant-man" && $scope.cinemaSelected=="GandhiMaidan"){
$scope.showTiming = $scope.showTiming2 ;
}
}
$scope.setSeatClass = function(){
$scope.isHide=true;
$scope.seatType = ['Platinum','Gold','Silver'] ;
} ;
$scope.getPrice = function(){
switch($scope.seatSelection){
case "Platinum":$scope.ticketPrice = 300;break;
case "Gold":$scope.ticketPrice = 240;break;
case "Silver":$scope.ticketPrice = 150;break;
}
}
$scope.bookTicket = function(){
$scope.movieName = $scope.movieSelected ;
$scope.getMovieDetails();
$scope.movieImg = $scope.moviePic;
$scope.loc = $scope.cinemaSelected;
$scope.timing = $scope.showTimeSelected;
$scope.seats = $scope.totalSeats;
$scope.seatSelection = $scope.seatSelected;
$scope.getPrice();
$scope.totalAmount = ($scope.seats*$scope.ticketPrice) ;
$scope.isHide=false;
}
}) ;
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController" ng-init="isHide=true">
<table width="500" border="1" cellspacing="2" cellpadding="3" style="float: left" >
<caption align="center"> <b>Online Movie Ticket Booking </b></caption>
<tr>
<td>
Select Your city<br>
<select ng-model="citySelected" ng-options="city for city in cities" ng-change="setCity()" ></select>
</td>
</tr>
<tr>
<td>
Select Cinema<br>
<select ng-model="cinemaSelected" ng-options="cinema for cinema in cinemaOptions" ng-change="setCinema()"></select>
</td>
</tr>
<tr>
<td>
Select Movie<br>
<select ng-options="movie for movie in movieOptions" ng-model="movieSelected" ng-change="setMovie()"></select>
</td>
</tr>
<tr>
<td>
Select Timings<br>
<select ng-options="timing for timing in showTiming" ng-model="showTimeSelected" ng-change="setSeatClass()"></select>
</td>
</tr>
<tr>
<td>
Select Class<br>
<select ng-options="seat for seat in seatType" ng-model="seatSelected" ng-change="isHide=true"></select>
</td>
</tr>
<tr>
<td>
Seats<br>
<input type="number" max="5" min="1" value="1" ng-change="isHide=true" ng-model="totalSeats"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="Book Now" ng-click="bookTicket()" >
</td>
</tr>
</table>
<!-- Booking Summary -->
<table width="400" border="2" cellspacing="3" cellpadding="3" style="float: left;margin-left: 100" ng-hide="isHide">
<caption align="center"> <b>Booking Details </b></caption>
<tr>
<td align="center">
Movie Name : <span style="margin-left:10">{{movieName}}</span>
</td>
</tr>
<tr>
<td>
<img ng-src="{{movieImg}}" width="300" height="240" style="margin: 20">
</td>
</tr>
<tr>
<td align="center">
{{timing}} at {{loc}}<br><br>
<span> Seat Type : {{seatSelection}} </span><br><br>
<span> total Seats : {{seats}} </span><br><br>
<span> Total Amount : ₹ {{totalAmount}} </span>
</td>
</tr>
</table>
</body>
</html>