$(document).ready(function() {
var today = new Date(new Date().getFullYear(), new Date().getMonth(),
new Date().getDate());
$('#startdate').datepicker({
uiLibrary: 'bootstrap4',
iconsLibrary: 'fontawesome',
format: 'dd/mm/yyyy',
maxDate: function() {
return $('#enddate').val();
}
});
$('#enddate').datepicker({
uiLibrary: 'bootstrap4',
iconsLibrary: 'fontawesome',
format: 'dd/mm/yyyy',
minDate: function() {
return $('#startdate').val();
},
});
$("#areaFormID").submit(function(event) {
event.preventDefault();
const currentlyClickedOutlet = $("#myselect").find(":selected")[0].textContent;
var currentlyClickedStartdate = $("#startdate").val();
var currentlyClickedenddate = $("#enddate").val();
var displayDates = ("For the date between '" + currentlyClickedStartdate + "' To '" + currentlyClickedenddate + "' and Outlet '" + currentlyClickedOutlet + "'");
$("#fromDatetoDate").html(displayDates);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7b75767b735c2d3225322a">[email protected]</a>/css/gijgo.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="583f31323f3718697661766e">[email protected]</a>/js/gijgo.min.js" type="text/javascript"></script>
<div id="fromDatetoDate"></div>
<!-- this one to show dates -->
<form id="areaFormID" method="get">
<div class="container">
<h4>Start Date:</h4>
<input type="text" id="startdate" name="fromdate" width="276" placeholder="dd/mm/yyyy" required />
<h4>End Date:</h4>
<input type="text" id="enddate" name="todate" width="276" placeholder="dd/mm/yyyy" required />
<h4>Outlets:</h4>
<select name="outlet" id="myselect">
<option>ALL</option>
<option>1</option>
<option>2</option>
</select>
<div>
<br>
<button id="btn-search" class="btn btn-default" type="submit">
<i class="fa fa-search"></i> Search
</button>
</div>
</div>
</form>
I have a date field and one select field whose values I am storing in a variable after user selects some values. I am then displaying them into a div container.
What I am trying to achieve is:
- To add CSS styling to the displayed information.
As a result of running the code, I get the line For the date between '05/01/2019' To '11/01/2019' and Outlet 'ALL'
- I aim to style the dates and outlet with specific colors and make them bold.
- Example: For the date between '05/01/2019' To '11/01/2019' and Outlet 'ALL'
- I am unsure how to apply CSS to jQuery variables.
Any guidance on this matter would be greatly appreciated.