hey guys im trying to get my html and python cgi script working together to show the users selections of the checkboxes of bulbs and add them up aswell plus the method they wana pay once they pretty the submit form button..

here is my html code:

<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="bulb1" type="checkbox" value="2.39"/></p>
  <p>8 x 100-watt light bulbs for $4.29:<input name="bulb2" type="checkbox" value="4.29"/></p>
  <p>4 x 100-watt long-life light bulbs for $3.95:<input name="bulb3" type="checkbox" value="3.95"/></p>
  <p>8 x 100-watt long-life light bulbs for $7.49:<input name="bulb4" type="checkbox" value="7.49"/></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"/>
<input type="submit" name="Submit" value="Submit Form"/>
<input type="reset"/>

here is my python cgi code:


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

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

def main():
   print "<html><head><title>Python Form</title></head><body>"
   form = cgi.FieldStorage()
   keyList = form.keys()
   for key in keyList:
            if key == form["bulb1"].value:
                print form["bulb1"].value + "<br>"
    print "</body></html>"


thank u

8 Years
Discussion Span
Last Post by jvignacio

You're welcome. :)

Do you have a question?

hha funny ! yeah well the codes arnt working the way i need it to work. As i described it above. any help ? i might have a few things wrong in my code.. i have my server running aswell so thats not the problem

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.