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
PythonHTML

Avatar of undefined
Last Comment
Dave Baldwin
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of jameskane
jameskane

ASKER

FABULOUS !!!!


many thanks Dave

james
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

You're welcome, glad to help.
HTML
HTML

HTML (HyperText Markup Language) is the main markup language for creating web pages and other information to be displayed in a web browser, providing both the structure and content for what is sent from a web server through the use of tags. The current implementation of the HTML specification is HTML5.

62K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo