Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

html onchange call js function

//Change the onchange to onChange="checkit(this); 
//and then something like the below in checkit

function checkit(selectObj)
{ 
  var idx = selectObj.selectedIndex;
  document.frm.Month.disabled = idx == 0;
}
Comment

html onchange call js function

<select name="region_id" class="form-select" required onChange="getDistricts(this);">
                                <option value="">-----------</option>
                                @foreach($regions as $region)
                                    <option value="{{ $region->id }}" {{ old('region_id', '') == $region->id ? 'selected' : '' }}>{{ $region->name_ru }}</option>
                                @endforeach
                            </select>

<script>
        function getDistricts(region_id) {
            var value = region_id.value;
            $.ajax({
                url: '/api/region/getDistricts/' + value,
                type: "GET",
                dataType: "json",
                success: function (data) {
                    var html = '';
                    $.each(data, function (key, value) {
                        html += '<option value="' + value.id + '">' + value.name_ru + '</option>';
                    });
                    $('select[name="district_id"]').html(html);
                    $('select[name="district_id"]').removeAttr('disabled');
                }
            });
        }
    </script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: create new angular project with specific version 
Javascript :: sanitizer content nodejs 
Javascript :: reverse string with recursion 
Javascript :: date format using javascript 
Javascript :: default Electron icon is used reason=application icon is not set 
Javascript :: sorting in javascript 
Javascript :: react usereducer 
Javascript :: create url with query parameters javascript 
Javascript :: select selected option value jquery 
Javascript :: Next js window is not defined solution 
Javascript :: How to get latitude and longitude from address in angular 6 
Javascript :: input type email react js-validation 
Javascript :: variable for every user discord.js 
Javascript :: puppeteer headless 
Javascript :: for each loop with arrowfunction 
Javascript :: generate numbers from 1 to 100 to array 
Javascript :: mui date picker width 
Javascript :: generate apk debug react native 
Javascript :: remove special characters in javascript 
Javascript :: express receive post data 
Javascript :: convert array to object 
Javascript :: generate random special characters javascript 
Javascript :: Burger menu bulma React 
Javascript :: clear interval js 
Javascript :: frequency of characters in a string in javascript 
Javascript :: get user country code javascript 
Javascript :: initialize function in javascript 
Javascript :: debouncing javascript 
Javascript :: countdown javascript 
Javascript :: js show element with focus 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =