jvignacio 0 Newbie Poster

hey guys havin some problems getting to add up the check boxes ticked in python from a form..

this is my html file:

<html>
<body>
<form action="cgi-bin/cost.py" method="POST">
  <p>Enter Name: <input name="name" type="text"/></p>
  <p>4 x 100-watt light bulbs for $2.39:<input name="4 100 watt" type="checkbox" value="$2.39"/></p>
  <p>8 x 100-watt light bulbs for $4.29:<input name="8 100 watt" type="checkbox" value="8 x 100-watt light bulbs for $4.29"/></p>
  <p>4 x 100-watt long-life light bulbs for $3.95:<input name="4 100 watt long" type="checkbox" value="4 x 100-watt long-life light bulbs for $3.95"/></p>
  <p>8 x 100-watt long-life light bulbs for $7.49:<input name="8 100 watt long" type="checkbox" value="8 x 100-watt long-life light bulbs for $7.49"/></p>
  <p>
    Visa:<input type="radio" name="card" value="Visa"/>
    MasterCharge:<input type="radio" name="card" value="MasterCharge"/>
    Discover:<input type="radio" name="card" value="Discover"/>
  </p>
 <input type="submit" name="Submit" value="Submit Form"/>
 <input type="reset"/>
</form>
</body>
</html>

and here is my python code.. it needs to add up what the user has ticked on the checkboxes in the form:

#!/apache2triad/python/bin/python.exe


import cgi
import sys
import httplib
import cgitb; cgitb.enable()

def header():
	print "Content-type: text/html"
	print
	main()

def main():
	print "<html><head><title>Python Form</title></head><body>"
	form = cgi.FieldStorage()
	keyList = form.keys()

	for key in keyList:
                
                            if key == keylist:
                                           print form["4 100 watt"].value + "<br>"
                    
	print "</body></html>"

header()

thank you for the help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.