I have this array which is named options_hotel, it has 2 arrays (but can have more depending on how many registries are fetched from DB)
both arrays have elements inside, such as ID, NOM & ADRESSE :
Array(2)
0: {ID: "1", NOM: "Le messager", ADRESSE: "30 rue du messager"}
1: {ID: "2", NOM: "hydrargyre", ADRESSE: "12 avenue hydrargyre"}
I have a select where options will be created dynamically,
<h2 class="list-titre">Hôtels</h2>
<select id="new_hotel"><!-- --></select>
Those options are created dynamically with javascript (& JQUERY), by getting NOM & ID from each hotel.
for(i=0; i<options_hotel.length; i++){
$("#new_hotel").append(new Option(options_hotel[i]['NOM'],options_hotel[i]['ID'] ));
}
Finally I have an input for adresses:
<h2 class="list-titre">Adresse</h2>
<input id="new_adresse" type="text" name="new_adresse" required>
So i want #new_adresse element to have the value of ADRESSE (which is stored in options_hotel) corresponding to the value of #new_hotel.
For instance : if the value inside #new_hotel is 1 (and the text is Le messager), then i want inside #new_adresse : 30 rue du messager.
Thank you
IDproperties of the array? Copying theADRESSEproperty to#new_adresse?ADRESSproperty to#new_adressewhich is the problem$("#new_adresse").val(obj.ADRESSE)whereobjis the found object.