Shopping cart tasklist
Shopping cart tasklist
Home page:
Design this page using html tags by using textboxes, dropdown list, text area, and
button.
Database: users
Code:
<script language="JavaScript">
function doRegister(){
var valid=true;
var errorMsg = "";
*/
var name=document.rform.fname.value;
var namecheck = new RegExp("^[a-zA-Z0-9\\d]+$","g");
if(name == "")
{
errorMsg += "\nNAME: Provide your first name\n";
}
else if(!name.match(namecheck))
{
var apos=document.rform.email.value.indexOf("@");
var dotpos=document.rform.email.value.lastIndexOf(".")
if(email=="")
{
var username=document.rform.uname.value;
var password=document.rform.password.value;
var repassword=document.rform.rpassword.value;
}
else if(!username.match(unamecheck))
{
errorMsg += "\nUSERNAME: Your username should not contain any
special characters except UNDERSCORE and should start with alphabet\n";
}
}
if((password.search("'"))>=0)
{
errorMsg+="\nPASSWORD: Please remove apostrophe from your
Password!\n";
if(password!=repassword)
{
errorMsg += "\nPASSWORDS: Passwords not matching\n";
}
if (errorMsg != "")
{
alert(errorMsg);
return false;
}
else
{
return true;
}
}
</script>
Login page:
Login to the application with the username & password in the ‘users’ table.
Login form validation:
Code:
<script language="JavaScript">
function doLogin(){
if(document.lform.uname.value=="" || document.lform.password.value==""){
alert("Please Provide username and password");
return false;
}
else{
return true;
}
}
</script>
In this application online shopping cart we can buy the products from the following
categories.
Automobiles
Electronic & computers
Home appliances
Jewelry
Mobiles & cameras
Toys & gifts
Automobiles:
Here when we click on the 1st category based on the category id it gets the details
and display.
Here we are selecting all fields from products table where cid=?
When u click on the link add to cart the products are added to your cart.
Cart information
Here we are inserting the product information in to the database table ‘cart’by
using insert query.
Keeping the values in the result set and displays the (product name, price, quantity
& total).
If we want to delete any product from the cart we can delete based on “id”
<%while(rs.next()){%>
<tr>
<td><%=rs.getString("pname")%></td> <td><%=rs.getString("price")
%></td><td><%=rs.getInt("qty")%></td><td><%=rs.getString("total")%></
td><td> <a href="delcart.jsp?id=<%=rs.getInt("id")
%>">delete</a></td>
</tr>
<%}%>
Or
If we click on the link “want to buy more” again the process continues as before.
If we click on check out we will get the total amount of our purchased products by
selecting all products from table ‘cart’ where uid=”?”
Now taking all the values from cart table and insert into ‘salesreport’ table and
caliculate the grand total of all the products.
Products
Salesreport:
#this process is same for all the categories of products in the above list.
Electronic & computers
Home appliances
Mobiles & camera