I have created an opportunity page layout in SalesForce.com and it is working fine. I have a situation where I need to add Airline information. I have created three fields and added these to the opportunity one by one; the HTML look like this:
<p>
<label>
<span>Airline 1:</span>
<span style="margin-left: 120px;">Airline 2:</span>
<span style="margin-left: 120px;">Airline 3:</span>
</label><br>
<input type="text" style="width: 150px;" class="text small" id="txtAirline" value="" name="txtAirline">
<input type="text" style="width: 150px;" class="text small" id="txtAirline2" value="" name="txtAirline2">
<input type="text" style="width: 150px;" class="text small" id="txtAirline3" value="" name="txtAirline3">
</p>
<p>
<label>
<span>PNR 1:</span>
<span style="margin-left: 130px;">PNR 2:</span>
<span style="margin-left: 130px;">PNR 3:</span>
</label><br>
<input type="text" style="width: 150px;" class="text small" id="txtPnr" value="" name="txtPnr">
<input type="text" style="width: 150px;" class="text small" id="txtPnr2" value="" name="txtPnr2">
<input type="text" style="width: 150px;" class="text small" id="txtPnr3" value="" name="txtPnr3">
</p>
Now, instead of adding filed for Airline and PNR again and again, I would like to add an “Add more” link which would create a clone of both fields and add it below one by one.
Is this possible?
The problem will be with binding. It would be fairly easy to write some Javascript that would do exactly what you want when they click a button but how will that data get back to the controller?
Perhaps you can try the following:
Create a custom object for the airline information. It can have whatever info you need. It will need to be tied to the Opportunity object via a relationship field (perhaps a Master-Detail type). In your opportunity you can then add a related list of airline information. MAke sure you add the airline info as part of the Layout. SFDC will handle most of the UI for you at that point – so it won’t look exactly as you have it set up – but it will do what you want to do.