Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

javascript select option attribute

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

<script>
  function getDistricts(region_id) {
      console.log(region_id);
  }
</script>

 
PREVIOUS NEXT
Tagged: #javascript #select #option #attribute
ADD COMMENT
Topic
Name
8+7 =