I am trying to implement an auto-complete field in a tabular inline model. Where a user selects a site and the address cell is consequently filled with the appropriate address I defined my fields in a form as below:
self.fields['sites'].widget = forms.Select(
attrs = {
'id': 'id_sites',
'onchange': 'getsiteaddress(this.value)',
'style': 'width:200px'
},
choices = sites_list,
)
self.fields['site_address'].widget = forms.TextInput(
attrs = {
'id': 'id_siteaddress',
'style': 'width:200px'
}
)
Everything works fine for the first row. My issue is that when I move to the second row of the inline model and select an address the cell of the first row is the one that changes. How can I call the second row?
This is my jQuery function
function getsiteaddress(site) {
let $ = django.jQuery;
$.get('/Delivery/deploymentsite/'+ site, function(resp) {
$('#id_siteaddress').val(resp.data)
});
}