Updating items in a shopping cart
We will try to create a simple page with a list of items with their price and quantity. The user will be able to select any number of a particular item and that information will be sent to the server side. The server-side script will calculate the prices of selections and will show the net price to the user.
This is similar to a shopping cart as you might have seen in many sites. The difference is that a page reload will not occur and the user will have to wait less. This recipe is a basic example and you can enhance it in many ways to suit your requirements.
Getting ready
Create a
folder named Recipe6
inside the Chapter6
directory. Next, under the same directory, create an XML file that will have a list of some books. Each book will have an ID, name, and a price. We will use this XML to display the list of books and select some books. Name this file as books.xml
.
<?xml version="1.0"?> <books> <book id="1"> <name>PHP Book<...