I am trying to get input text from html scala templete form with jquery that the value of that input text is the date and i pass it to the controller to be converted into date format then be reused on the interface but i get null value ,please help me.
scala tamplete:
...........
<form class="" role="form" id="mapform">
<table width="1000" >
<tr>
<td width="500">
<div class="form-group col-sm-6">
<select name="names" class="form-control"
id="dropdown" required="true">
<option value=""> </option>
@for(d <- Driver_registrationInfo.findAll()){
<option id="namesId" name="names" value="@d.names"> @d.names </option>
}
</select>
</div>
</td>
<td width="500" >
<div class="form-group col-sm-8">
<div class="col-lg-10">
<div class='input-group date' id="datetimepicker8">
<input type='text' class="form-control message" id="datesfield" name="dateSelect" required="true"/>
<span class="input-group-addon">
<i class="fa fa-calendar" aria-hidden="true"></i>
</span>
</div>
</div>
</div>
</td>
<td>
<div class="form-group ">
<input type='submit' class="form-control btn btn-danger" id="plot_marker" value="Track" />
</div>
.................
Jquery function :
.....
$('#plot_marker').click(function(e){
e.preventDefault();
var ioId2 = document.getElementById('datesfield').value;
if(ioId2 ) {
var nextUrl = "/searched/";
window.location = nextUrl;
}
......
Controller:
......
public static Result searched() {
Form<Coordinates> coordinatesForm =
Form.form(Coordinates.class).bindFromRequest();
String names = coordinatesForm.field("names").value();
// selected date on form convert it to string
Date dateSelect = new
Date(coordinatesForm.field("dateSelect").value());
DateFormat df = new SimpleDateFormat("yyy-MM-dd");
String DateString = df.format(dateSelect);
return ok(admin.render(names, DateString));
}
......