Hi I am working on a school project where I need to make an order form for a website using python and HTML. I am having trouble adding these:
if form.getvalue("interior"):
print "<p>Interior Painting(s) quantity:", form["quantity"].value, "</p>"
print "<p>You Cost is :$" ,int(form["quantity"].value)*2, ".00</p>"
else:
print "<p>Interior Painting(s) ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("exterior"):
print "<p>Exterior Painting quantity:", form["quantity2"].value, "</p>"
print "<p>You Cost is :$" ,int(form["quantity2"].value)*1, ".00</p>"
else:
print "<p>Exterior Painting(s) ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("pressure"):
print "<p>Pressure Washing quantity:", form["quantity3"].value, "</p>"
print "<p>You Cost is :$" ,int(form["quantity3"].value)*150, ".00</p>"
else:
print "<p>Pressure Washings(s)ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("wood"):
print "<p>Wood Finishing quantity:", form["quantity4"].value, "</p>"
print "<p>You Cost is $" ,int(form["quantity4"].value)*3, ".00</p>"
else:
print "<p>Wood Finsihings(s) ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("spraycan"):
print "<p>Spray Can quantity:", form["quantity5"].value, "</p>"
print "<p>You Cost is $" ,int(form["quantity5"].value)*10, ".00</p>"
else:
print "<p>Spray Cans ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
I am trying to add all the int(form[quantity..1..2].value all together and display a result after these. I have tried assigning the form[quantity].value to a varaible and adding them up but it isnt working. Also since getvalue only executes when the user selects the option, how can i go about doing this? Thanks.
FULL CODE
import cgi
form = cgi.FieldStorage()
# print HTTP/HTML header stuff
print """Content-type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<title>Order Form</title>
</head><body>
"""
# print HTML body using form data
print "<h1>Profesional Painters</h1>"
print "<h2>Customer Reciept</h2>"
print "<p>Customer Name:", form["customerName"].value, "</p>"
print "<p>Customer Email Address:", form["customerEmail"].value, "</p>"
print "<h2>Customer Address:</h2>"
print "<p>Street:", form["customerAdd"].value, "</p>"
print "<p>City:", form["customerCity"].value, "</p>"
print "<p>Province:", form["customerProv"].value, "</p>"
print "<p>Postal Code:", form["customerPostal"].value, "</p>"
print "<h2>Payment Information:</h2>"
print "<p>Card Type:", form["type1"].value, "</p>"
print "<p>Card Number: XXXX-XXXX-XXXX-", form["four4"].value, "</p>"
print "<p>Expiry Date:", form["expirt"].value, "</p>"
print "<h2>Products Ordered</h2>"
if form.getvalue("interior"):
print "<p>Interior Painting(s) quantity:", form["quantity"].value, "</p>"
print "<p>You Cost is :$" ,int(form["quantity"].value)*2, ".00</p>"
else:
print "<p>Interior Painting(s) ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("exterior"):
print "<p>Exterior Painting quantity:", form["quantity2"].value, "</p>"
print "<p>You Cost is :$" ,int(form["quantity2"].value)*1, ".00</p>"
else:
print "<p>Exterior Painting(s) ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("pressure"):
print "<p>Pressure Washing quantity:", form["quantity3"].value, "</p>"
print "<p>You Cost is :$" ,int(form["quantity3"].value)*150, ".00</p>"
else:
print "<p>Pressure Washings(s)ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("wood"):
print "<p>Wood Finishing quantity:", form["quantity4"].value, "</p>"
print "<p>You Cost is $" ,int(form["quantity4"].value)*3, ".00</p>"
else:
print "<p>Wood Finsihings(s) ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("spraycan"):
print "<p>Spray Can quantity:", form["quantity5"].value, "</p>"
print "<p>You Cost is $" ,int(form["quantity5"].value)*10, ".00</p>"
else:
print "<p>Spray Cans ordered: <b>0</b> <br /> Cost: <b>$0</b></p>"
if form.getvalue("email"):
print "<p>An email notification will be sent to ",form["customerEmail"].value, "</p>"
print "</body></html>"
jinja2
.