I have a collection of checkboxes, each with its own unique ID. When a checkbox is clicked, I need to extract the ID and generate a string like '/some/path/?myids=checkOne,checkTwo' (where checkOne and checkTwo are IDs of two different checkboxes that have been selected).
While I understand that state management can be used for this, my challenge lies in limiting the number of checkboxes that contribute to creating the custom string. Specifically, I want to restrict it to only include 5 comma-separated IDs. Due to the constraints of AMP logic, implementing this level of complexity is proving difficult.
The process should follow these steps:
- Display a set of checkboxes.
- Allow users to select any checkbox.
- Upon clicking a checkbox, update an anchor tag href attribute by adding the substring '?myids=checkOne'.
- If another checkbox is clicked, update the href tag to include additional IDs, such as '?myids=checkOne,checkTwo', and continue up to a maximum of 5 selected checkboxes.
Is this achievable? Thank you for your help.
Unfortunately, the documentation does not provide clear guidance on handling complex logic within AMP, and limited resources were found through searching online.