?
Solved

Embedding Python Functions with HTML table

Posted on 2014-11-06
3
Medium Priority
?
268 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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

752 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