O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining a relation between form fields

Another neat feature that Lift provides is Cells, which like cells in a spreadsheet can be wired together, so when the value of one cell changes, it automatically updates the value of another one.

In this recipe, I'll mix Ajax forms with Cells to teach you how to create a dynamic shopping cart. Thus, when the user updates the quantity of a given item he or she wants to purchase, the total amount per item and the total shopping cart amount will be updated.

Getting ready

You can use the code from the examples we've used in the previous recipes, or you can start a new project.

Modify the index.html file by removing everything inside the div tag, with main as the value of the id field, and add the following code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required