I have a vf table allowing people to add multiple records, it is basically a booking for to book people onto an event.
I have some js that populates the record.Name field using two of the other fields.
<apex:selectList value="{!selectedType}" multiselect="false" html-data-sellist="1" size="1" id="sellist">
<apex:inputField value="{!del.Name__c}" id="inpfield" required="true" html-data-inpfield="1" onchange="updatehidden()"/>
<apex:inputHidden value="{!del.Name}" html-data-inpnew="1" id="inpnew"/>
<script>
function updatehidden() {
var sellist = document.querySelector("[data-sellist]").value,
inpfield = document.querySelector("[data-inpfield]").value,
inpnew = document.querySelector("[data-inpnew]");
inpnew.value = sellist + ' - ' + inpfield
}
</script>
The js only seems to run on the first row of the table, not sure why.
I have a command link button at the bottom of the page that will List.add(new delegate__c()) which then adds a blank row to the table. However I'd have thought that the onchange() would also be invoked on the second, third row etc.
When multiple rows are added it saves fine but creates the record with the id as the record.name.
Does anyone have any idea why?
Thanks