I have the following piece of code within my cshtml file. There are two fields which I am using autocomplete for:
<div class="Wrapper">
@using (Html.BeginForm("GetDetails", "TrainInfo", FormMethod.Post))
{
<div id="station_row">
From <input type="text" placeholder="Departure Station" id="depart" name="DeptStation">
to <input type="text" placeholder="Arrival Station" id="arrive" name="ArrvStation">
</div>
<div id="date_time">
When: <input type="text" id="datepicker" name="DeptDate">
At: <input type="text" class="timepicker" name="time">
</div>
<div id="go_button">
<button type="submit" name="Submit">Go</button>
</div>
}
</div>
@section scripts
{
<script type="text/javascript">
(function ($) {
$("#datepicker").datepicker({ dateFormat: "yy-mm-dd" });
})(jQuery);
</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
<script type="text/javascript">
(function ($) {
$('.timepicker')
.timepicker({
timeFormat: 'h:mm p',
interval: 15,
minTime: '00:00',
maxTime: '11:45pm',
defaultTime: '00',
startTime: '0:00',
dynamic: false,
dropdown: true,
scrollbar: true
});
})(jQuery);
</script>
<script>
$(function () {
var availableTags = [
@{
GetAllStationsForUi stationNames = new GetAllStationsForUi(new DatabaseConnection(System.Configuration.ConfigurationManager.ConnectionStrings["TrainTimes"].ConnectionString));
var station = stationNames.GetAllPossibleStations().Select(i => "\"" + i + "\"").Aggregate((s1, s2) => string.Format("{0},{1}", s1, s2));
@Html.Raw(station)
}
];
$("#depart").autocomplete({
source: availableTags
});
$("#arrive").autocomplete({
source: availableTags
});
});
</script>
}
When I select one option from either of the boxes, I want this option to be removed from the other selection. Does anyone have any idea on how this can be done?