Solved

Embedding Python Functions with HTML table

Posted on 2014-11-06
3
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

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 83

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

691 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