source: Application/ocrent/Views/Search/Index.cshtml

Last change on this file was f5f7c24, checked in by 192011 <mk.snicker@…>, 17 months ago

Initial commit

  • Property mode set to 100644
File size: 3.7 KB
Line 
1@model Models.ViewModels.SearchViewModel
2
3{
4 ViewData["Title"] = "Search";
5}
6
7<div class="container py-5 search-area">
8 <h1 class="text-light">Find your car</h1>
9 <form class="search-wrapper" method="post" enctype="multipart/form-data" >
10 <div class="d-flex justify-content-center align-items-center flex-column">
11 <label for="city-list">Select city</label>
12 @Html.DropDownListFor(x => x.Locations, new SelectList(@Model.Locations, "CityName", "CityName"), "", new { @class = "form-control", id="city-list"})
13 </div>
14 <div class="d-flex justify-content-center align-items-center flex-column">
15 <label for="brand-list">Select brand</label>
16 @Html.DropDownListFor(x => x.Brands, new SelectList(@Model.Brands, "BrandName", "BrandName"), "", new { @class = "form-control", id="brand-list"})
17 </div>
18 <div class="d-flex justify-content-center align-items-center flex-column">
19 <label class="m-1 form-label" for="kt_daterangepicker_1">Select date & time</label>
20 <input id="picker" class="form-control" style="min-width: 350px;" name="dates" autocomplete="off" id="kt_daterangepicker_1" required />
21 </div>
22 <div class="d-flex justify-content-center align-items-center">
23 <input type="button" id="searchBtn" class="search-btn" value="Search" />
24 <div class="triangle"></div>
25 </div>
26 </form>
27</div>
28
29@section Scripts {
30 <script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
31 <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
32 <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
33 <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
34 <script>
35 $(document).ready(function () {
36 $('input[name="dates"]').daterangepicker(
37 {
38 locale: {
39 format: 'DD/MM/YYYY'
40 }
41 }
42 );
43
44 $("#searchBtn").on('click',function(){
45 var city = $("#city-list").find(":selected").text();
46 var brand = $("#brand-list").find(":selected").text();
47
48
49 var startDate = $('#picker').data('daterangepicker').startDate.format('DD-MM-YYYY');
50 var endDate = $('#picker').data('daterangepicker').endDate.format('DD-MM-YYYY');
51
52 console.log(city);
53 console.log(brand);
54 console.log(startDate);
55 console.log(endDate);
56
57 sentSearchResult(city,brand,startDate,endDate);
58 })
59
60 function sentSearchResult(city,brand,startDate,endDate){
61 var data = {};
62 data.City = city;
63 data.Brand = brand;
64 data.StartDate = startDate;
65 data.EndDate = endDate;
66
67 var token = $("input[name='__RequestVerificationToken']").val();
68
69 $.ajax({
70 type: "POST",
71 headers:
72 {
73 "RequestVerificationToken": token
74 },
75 url: "@Url.Action("SearchData","Search")",
76 data: {
77 data: data,
78 },
79 success: function (data) {
80 window.location.href = data;
81 },
82 error: function (req, status, error) {
83 }
84 })
85 }
86 });
87 </script>
88}
Note: See TracBrowser for help on using the repository browser.