I have an array data below:
<?php
$names = array('Ireneo Crodua' => array('Australia', 'contact 3883 441', 'id_01'),
'Almads Bangal' => array('India', 'contact 3883 811', 'id_02' ),
'Rechard Canonigo' => array('America', 'contact 3883 333', 'id_03'),
'Marjohn bebeloni' => array('China', 'contact 3883 444', 'id_04')
);
?>
I have a select box to select the name of the person
<form action="post">
<p><label>Select Name</label>
<select>
<?php
foreach($names as $name => $place){
echo "<option>" . $name . "</option>";
}
?>
</select>
</p>
<p><label>Place</label><input name="place" value="" /></p>
<p><label>Contact</label><input name="contact" value="" /></p>
<p><label>ID Number</label><input name="id_number" value="" /></p>
</form>
is that posible if I select for example Rechard Canonigo
in my select box the array value for Rechard Canonigo
will appear automatically in input field.
example:
America will automatically appear in input field => place
and contact 3883 333
will also appear in input field => contact
and the last the id_03
will appear in id_number
input field
I fount this jquery code:
$(function(){
$('select').on('change',function(){
$('input[name=place]').val($(this).val());
});
});
work similar in what i want to achieve but the problem is it only give one result in the array