我试图传递变量的值" currentDate"改变"日"这样,无论用户选择何种日期,我都会在getDay方法中获得相应的值, 例如,如果用户选择日期03/21/2018,即使用getDay的值应为' 3' 实现:,对于每个选定的日期,我想使用getDay
获得相应的值welcome.html
{% extends 'base.html' %}
{% load bootstrap %}
{% block content %}
<title>welcome</title>
<p id="demo"></p>
<p id = "demo1"></p>
<script>
var date = new Date();
document.getElementById("demo").innerHTML = d;
</script>
<form action = " " method = "GET" role="form">
{% csrf_token %}
<table>
{{form|bootstrap}}
<script>
$(document).ready(function() {
$('.datepicker').datepicker();
var currentDate = $( ".selector" ).datepicker( "getDate" );
var day = currentDate.getDay();
window.alert(day);
});
</script>
</table>
<div class = "form-group">
<input type ="submit" value= "CHECK" class="form control"/>
</div>
</form>
{% endblock %}
base.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div style = "background-color:#9f9">
<h1>Itam Market</h1>
</div>
<div style = "background-color:#0fc " >
<h1>welcome please pick a date</h1>
</div>
{% block content %}
{% endblock %}
{% block footer %}
<hr>
<p>Thanks for visiting my site.</p>
{% endblock %}
</body>
</html>