Worth the script http://webersoft.ru/select-ajax-mysql/ Please tell me how to remove the choice of the country in it so that there is only a region and a city. thank
Closed due to the fact that off-topic participants pavel , aleksandr barakin , cheops , Bald , Denis Oct 7 '16 at 6:37 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - aleksandr barakin, Bald, Denis
- 3In the regions select the regions, remove the country field and extra ajax request to get the regions. remove get_regions.php as unnecessary. For yourself, you need to understand the logic of the script before using it. - Alex
- Sample code should be contained in the question itself. Links are allowed only for clarification - Alexey Prokopenko
- In the form add options regions in select regions. There is a download from a php file - Vitaly Nosikov
|
1 answer
- Remove the extra
selectto select countries from the form - In the form add
optionsregions inselectregions - In the line
<select name="region_id" id="region_id" disabled="disabled" class="StyleSelectBox">removedisabled="disabled". - In the
selects.jsfileselects.jsdelete the extra ajax request to get the countries - Delete the get regions file get_regions.php as unnecessary.
/*selects.js*/ /* * При полной загрузке документа * мы начинаем определять события */ $(document).ready(function() { /* * Те же действия проделываем с выбором города */ $('#region_id').change(function() { var region_id = $('#region_id :selected').val(); if (region_id == '0') { $('#city_id').html('<option>- выберите город -</option>'); $('#city_id').attr('disabled', true); return (false); } $('#city_id').attr('disabled', true); $('#city_id').html('<option>загрузка...</option>'); var url = 'get_city.php'; $.get( url, "region_id=" + region_id, function(result) { if (result.type == 'error') { alert('error'); return (false); } else { var options = ''; $(result.citys).each(function() { options += '<option value="' + $(this).attr('city_id') + '">' + $(this).attr('name') + '</option>'; }); $('#city_id').html('<option>- выберите город -</option>' + options); $('#city_id').attr('disabled', false); } }, "json" ); }); }); <form action="#" method="get"> Регион: <br /> <select name="region_id" id="region_id" class="StyleSelectBox"> <option value="0">- выберите регион -</option> <!-- Здесь добавляете options со всеми регионами --> </select> </td> <td> Город: <br /> <select name="city_id" id="city_id" disabled="disabled" class="StyleSelectBox"> <option value="0">- выберите город -</option> </select> </form> - Alex can the correct code please? - Vitaly Nosikov
- Please specify which code you need. The response indicates the final form code and the final
selects.jscode. You just need to add theoptionsregions to the form. and use the city receipt file from the script you specified. - Alex - In Html I did, if possible select.js. Made select region to be clickable does not work <label for = "region_id"> Select region: </ label> <br/> <select name = "region_id" id = "region_id" disabled = "disabled" class = "StyleSelectBox"> <option value = "0"> - select region - </ option> </ select> <br/> <label for = "name"> Select city: </ label> <br/> <select name = "name" id = "name" disabled = "disabled" class = "StyleSelectBox"> <option value = "0"> - select a city - </ option> </ select> <br/> - Vitaly Nosikov
- besides the form, what did you do? connected scripts, set up a connection to the database or not? - Alex
- Yes, I connected everything, everything works, but I only need the region and the city, that is, without a choice of country - Vitaly Nosikov
|