Нет, переменные не раскрываются в action
атрибутах.Вы можете изменить атрибут в функции.
Я также изменил обработчик на событие submit
, поэтому вам не нужно явно вызывать .submit()
.
$(document).ready(function() {
$(function() {
$("#datepicker").datepicker();
});
$("#myForm").submit(function() {
var currentDate = $("#datepicker").datepicker("getDate");
$("#testForm").attr("action", `http://localhost:8080/LocWebService/rest/tracollect/${currentDate}`);
});
});
<body>
<form name="myForm" id="testForm" method="GET" action="http://localhost:8080/LocWebService/rest/tracollect/currentDate">
Date: <input type="text" id="datepicker">
</form>
<br/>
<input type="button" id="submit1" value="SUBMIT" />
</body>