Using web forms to automatically add items to a wishlist

Updated on 20-October-2016 at 10:16 AM

Business Catalyst End of life announcement - find out more details.

Using a simple JavaScript function, you can automatically add an item to a visitor's wishlist list by updating an existing web form. Take a look at the Implementing a members only area "wishlist" article for detailed steps on how to implement this feature.

For details on web forms, see Create and insert a form .

Note: This behavior will only function for visitors that are logged into a Secure Zone; the system must be able to identify the visitor in order to display the Favorites list and add the specified item to it.

First, add the following HTML code to the page:

Then, add the JavaScript function that will add the item to the Favorites list. It will look similar to this:

Finally, edit the source code for the web form to call the function above (AddToFavorites) before it submits the form.

This method adds the item to the visitor's wishlist list before the form is submitted.