Hello, I'm still new to this but Is there a way to create an single line and under in single line there an add and delete button or icon. For example A student fill out a form put in there college course and they want add another course they click on the Add button and add another course in the next single line. Is there a way to create this in forms?? If you don't understand this question please me know and I will go in more detail... Also here are some example
Question
Question
How to create an add and delete button and functionality in Laserfiche forms
Replies
I think this is what you are trying to do...
This worked in my own testing, other than I occassionally had to click the buttons twice before they worked, I think it is a focus issue, but I couldn't quite nail it down.
This assumes that your table has Class Name of myTable, that one of the Single-Line fields in your table has Class Name of myTableField, and that field has the checkbox marked for "Previous data and new rows with lookup data will be read-only, but user-added rows will be editable."
Add this CSS to your form:
/*Set the appearance of the custom Add and Delete buttons on the table*/ .myButton { display: inline-flex; align-items: center; font-size: 14px; position: relative; max-height: 30px; min-height: 30px; background-color: #007bff; color: white; border: 0px; border-radius: 7px; }
Add this Javascript to your form:
$(document).ready(function() { //When the form loads, call the RemoveDeleteFromDisabledRows and ReplaceDeleteAndAddWithButtons functions. $('.myTableField input').each(RemoveDeleteFromDisabledRows); $('.myTableField input').each(ReplaceDeleteAndAddWithButtons); //When the table changes, call the RemoveDeleteFromDisabledRows and ReplaceDeleteAndAddWithButtons functions. $('.myTable').change(RemoveDeleteFromDisabledRows); $('.myTable').change(ReplaceDeleteAndAddWithButtons); //When rows are added to the table, call the RemoveDeleteFromDisabledRows and ReplaceDeleteAndAddWithButtons functions. $('.cf-table-add-row').click(RemoveDeleteFromDisabledRows); $('.cf-table-add-row').click(ReplaceDeleteAndAddWithButtons); //When this function is called, it will cycle through each table row and if the myTableField //field is disabled, it will remove the option to delete that row from the table. function RemoveDeleteFromDisabledRows() { if($(this)[0].hasAttribute("readonly")) { $(this).closest('li').find('.form-del-field').remove(); } } //When this function is called, it will cycle through each table row and replace the delete //x's with delete buttons, and the add link with add button. function ReplaceDeleteAndAddWithButtons() { $(this).closest('li').find('.form-del-field').html('<button class="myButton">Delete</button>'); $('.cf-table-add-row').html('<button class="myButton">Add +</button>'); } });
End result looks like this:
All this is doing is replacing the links for the add and delete items in the table with custom buttons.
Yes, you should be able to do that by:
- Setting the row options on the collection or table to be “Append rows to the rows populated by a data source or variable”.
- Setting the Field options on the table column fields or lookup target fields to be “Previous data or new lookup data will be read-only, but user-added sets will be editable”
And you can set the minimum to be 0 if you don’t want any pre-appended-editable rows at the bottom.
These settings can achieve the following:
- Previous data or lookup data will be read-only and cannot be deleted at the top
- Users can manually add data that will be editable and deletable at the bottom