Solved

Embedding Python Functions with HTML table

Posted on 2014-11-06
3
229 Views
Last Modified: 2014-11-06
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
0
Comment
Question by:jameskane
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40425865
They're not being 'triggered' because you have them in the text for the 'print' statement.  You need to separate them.  This is a fairly common problem in many languages.  Try this.  You may have to adjust the indentation.
       print("<tr>")
            print("<td colspan='2'>")
            createDropDown(Inches)
            print("</td>")
            print("<td colspan='2'>")
            createDropDown(CakeName)
            print("</td>")
            print("</tr>")

Open in new window

0
 

Author Closing Comment

by:jameskane
ID: 40425917
FABULOUS !!!!


many thanks Dave

james
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 40426975
You're welcome, glad to help.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now