top of page

Unique Item Reference Code for Collection Items

Learn how to create a unique reference code as items are inserted into a collection using Corvid (a.k.a. Wix Code). Unique reference numbers are an easy way for you or your website users to search or locate a specific item in your collection.

​This example allows you to add shapes to a collection called #Shapes, automatically allocating each new shape a unique reference code of the format REF0#. Try the example below.

Add Shape
#btnAddShape
Try it!
#iptShape
#txtMessage
Select a shape to add to the collection
#repShapes

Square

Rectangle

Circle

Triangle

Triangle

Square

When the button #btnAddShape is clicked, a query is executed directly on the #Shapes collection to find the reference code of the most recent shape entered. If the collection is empty to start with, then the new shape is inserted with a reference code of REF01. If the collection already contains shapes, the reference code of the most recent shape is taken and iterated by 1 before inserting the new shape into the collection. Once the new shape has been inserted, the repeater displaying the collection refreshes. 

Page Code

Please wait ...
Unlock
Disclaimer: To the best of our knowledge, this code works for its stipulated purpose. If you find an error in our code, or know of a better way to achieve the same result - please contact us! All our code snippets come with full support to help you implement them on your own website - simply contact us for help.
bottom of page