| <! Doctype html> <Html> <Head> <Title> cart </title> <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> <! -- To import the jquery-1.9.1.min.js, do not export the terminal --> <Script type = "text/javascript" src = "jquery-1.9.1.min.js"> </script> <Script language = "javascript"> $ (Function (){ Var size = 3.0 * $ ('# image1'). width (); $ ("# Image1"). mouseover (function (event ){ Var implements targetmediaworkflow (event.tar get ); If ($ target. is ('img ')) { $ (" "Height": size, "Width": size, }). AppendTo ($ ("# imgtest");/* append all matching elements to the end of the specified element. */ } }). Mouseout (function (){ $ ("# Tip"). remove ();/* remove element */ }) }) </Script> <Script type = "text/javascript"> Function total (id) { /* Calculate a single price */ Var quantity = document. getElementById ("quantity" + id). value; Var price = document. getElementById ("price" + id). value; Var smallTotal = quantity * price; Var smallT = document. getElementById ("smallTotal" + id ); SmallT. innerHTML = smallTotal; /* Calculate the total price */ Var totalPrice = 0; For (var a = 1; a <3; a ++ ){ Var quantity = document. getElementById ("quantity" + a). value; Var price = document. getElementById ("price" + a). value; Var smallTotal = quantity * price; TotalPrice = totalPrice + smallTotal; } Var total = document. getElementById ("total "); Total. innerHTML = totalPrice; } </Script> <Script type = "text/javascript"> Function initialize () { Var totalPrice = 0; For (var a = 1; a <3; a ++ ){ Var quantity = document. getElementById ("quantity" + a). value; Var price = document. getElementById ("price" + a). value; Var smallTotal = quantity * price; TotalPrice = totalPrice + smallTotal; /* Alert (smallTotal );*/ Var smallT = document. getElementById ("smallTotal" + ); SmallT. innerHTML = smallTotal; } /* Retrieve the total prices of all items in the shopping cart */ Var total = document. getElementById ("total "); Total. innerHTML = totalPrice; } </Script> <Style type = "text/css"> # Imgtest { Position: absolute; Top: 100px; Left: 400px; Z-index: 1; } Table { Left: 100px; Font-size: 20px; } </Style> </Head> <Body onload = "initialize ()"> <Div id = "imgtest"> </div> <Br/> <Br/> <Table border = "1" style = "text-align: center;" align = "center"> <Thead style = "height: 50"> <Td style = "WIDTH: 300px"> Product Name </Td> <Td style = "WIDTH: 60px"> Image </Td> <Td style = "WIDTH: 170px"> Quantity </Td> <Td style = "WIDTH: 170px"> Price </Td> <Td style = "WIDTH: 250px"> Subtotal </Td> </Thead> <Tbody> <Tr> <Td class = "name"> Item 1 </td> <Td class = "image"> </Td> <Td class = "quantity"> <Input id = "quantity1" value = "1" onblur = "total (1);"/> </Td> <Td class = "price"> <Input type = "hidden" id = "price1" value = "20"/> 20 </Td> <Td class = "total"> <Span id = "smallTotal1"> </span> Meta </Td> </Tr> <Tr> <Td class = "name"> Item 2 </td> <Td class = "image"> </Td> <Td class = "quantity"> <Input id = "quantity2" value = "2" onblur = "total (2);"/> </Td> <Td class = "price"> <Input type = "hidden" id = "price2" value = "30"/> 30 </Td> <Td class = "total"> <Span id = "smallTotal2"> </span> Meta </Td> </Tr> <Tr> <Td colspan = "4" class = "cart_total"> <Br> </Td> <Td> <Span class = "red"> total: </span> <span id = "total"> </span> RMB </Td> </Tr> </Tbody> </Table> </Body> </Html> |