Link to home
Start Free TrialLog in
Avatar of jameskane
jameskane

asked on

Embedding Python Functions with HTML table

I have a Python Function createForm(CakeName,Inches)  for creating a FORM with two sets List/Menus. This Form function contains  two further embedded functions -  createDropDown(Inches) and createDropDown(CakeName) for creating the List/Menus.

The number of List/Menus in each set is determined by the customer. If he orders 7 cakes, then he will be presented with seven identical List/Menus allowing him to choose which cake type/name is required. He will also be presented with a further seven identical List/Menus which will allow for choosing the cake size. Clearly these two sets of List/Menu's need to be aligned horizontally.  This is the problem.

Layout_No_Table.jpg attached shows the layout as it now is - these are not aligned horizontally. The CreateForm(CakeName, Inches) is shown below. My problem is how to modify this function to get proper alignment.

 ..................................................................................................................................................................................................
def createForm(CakeName,Inches):
      print("""<form method="post" action="orderformAction.cgi">""")
      for i in range(n):  
            createDropDown(CakeName)
            createDropDown(Inches)
   
      print("""<input type="submit" name="submittest" value="Submit" />""")
      print("</form>")



Layout-with-table.jpg attached shows the result when I try and use html tables within the python function code to achieve the layout. You will see the at the layout problem is solved, but the embedded functionsCreateDropDown(CakeName) and CreateDropDown(inches) are not triggered.  The form function with the embedded table is shown below

.......................................................................................................................................................................................
def createForm(CakeName,Inches):
      print("""<form method="post" action="orderformAction.cgi">""")
      print("<table width='511' border='1' cellspacing='0' cellpadding='0'>")
      print("<caption>")
      print("CAKE SHOP")
      print("</caption>")
      #print("<tr>")
      #print("<th colspan='2' scope='col'>Choose Cake Types and Sizes</th>")
      #print("</tr>")
      print("<tr>")
      print("<td colspan='2'>&nbsp;</td>")
      print("</tr>")    
      for i in range(n):
            print("<tr>")
            print("<td colspan='2'>createDropDown(Inches)</td>")
            print("<td colspan='2'>createDropDown(CakeName)</td>")
           
            print("</tr>")
      print("</table>")
      print("""<input type="submit" name="submittest" value="Submit" />""")
      #print("</table>")
      print("</form>")


In summary, I need to know how to align the form elements as needed. It seems that its not possible to embed html tables into the form function to achieve this alignment.  Any ideas fixes appreciated !!

many thanks

james
layout-NO-TABLE.jpg
layout-WITH-TABLE.jpg
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jameskane
jameskane

ASKER

FABULOUS !!!!


many thanks Dave

james
You're welcome, glad to help.