0.0.38 upd sendRoute.js

This commit is contained in:
2023-07-25 13:44:56 +03:00
parent 4c569165f1
commit 7a3cb01e35
3 changed files with 31 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
function searchTown(el){
let timer = null
if (timer) {
clearTimeout(timer);
@@ -36,15 +37,14 @@ function searchTown(el){
function selectItemAddrPoint(id, name, ctrl_name){
function selectItemAddrPoint(id, name, ctrl_name,){
let input_list = document.getElementsByName(ctrl_name + '_list')[0];
let tap_txt_cont = document.querySelector("#id_" + ctrl_name);
tap_txt_cont.value = name;
let tap_cont = document.querySelector("#id_" + ctrl_name.slice(0, -4));
tap_cont.value = id;
let clear_search_list = document.querySelector(".input_list")
clear_search_list.classList.remove('show')
input_list.classList.remove('show');
}
@@ -61,4 +61,17 @@ function insertSearchList(data, ctrl_name) {
input_list.classList.remove("show");
}
}
function onblurInputField(event,el){
// if(el.classList.contains("from_country_container")){
let search_list = document.getElementsByName(el.name + '_list')[0];
let parent_event = $(event.explicitOriginalTarget).parents('.input_list' );
if(!parent_event || parent_event[0] !== search_list){
search_list.classList.remove('show')
}
// }
}

View File

@@ -38,3 +38,14 @@ function sendRoute(el){
//cleaning route inputs after selection changes
function OnSelectionChange() {
document.getElementById("id_from_address_point_txt").value = '';
document.getElementById("id_to_address_point_txt").value = '';
}

View File

@@ -9,7 +9,7 @@
<label for="id_type_transport">{{ form.fields.type_transport.label }}</label>
</div>
<div>
<select name="type_transport" id="id_type_transport"{% if form.fields.type_transport.required %} required{% endif %}>
<select onchange="OnSelectionChange(this)" name="type_transport" id="id_type_transport"{% if form.fields.type_transport.required %} required{% endif %}>
{% for item in form.fields.type_transport.choices %}
<option value="{{ item.0 }}"{% if form.fields.type_transport.initial == item.0 %} selected="selected"{% endif %}>{{ item.1 }}</option>
{% endfor %}
@@ -38,12 +38,11 @@
</div>
<hr>
<div class="from_to_country">
<div>
<div class="from_country_container">
<label for="id_from_address_point">{{ form.fields.from_address_point.label }}</label>
<input type="number" name="from_address_point" id="id_from_address_point" hidden />
<input oninput="searchTown(this)" type="text" name="from_address_point_txt"{% if form.fields.from_address_point.required %} required{% endif %} id="id_from_address_point_txt">
<input oninput="searchTown(this)" onblur="onblurInputField(event, this)" type="text" name="from_address_point_txt"{% if form.fields.from_address_point.required %} required{% endif %} id="id_from_address_point_txt">
<div class="input_list" name="from_address_point_txt_list">
</div>
{% if form.errors and form.errors.from_address_point %}
<span>{{ form.errors.from_address_point}}</span>