Convert database results or static html page to em

Results 1 to 3 of 3

Thread: Convert database results or static html page to em

  1. #1
    Join Date
    Dec 1969

    Default Convert database results or static html page to em

    OK - I have a shopping basket with data in a database. Once the person has successfully completed their order I want to be able to send them an email with the products ordered roughly in the following format:<BR><BR>Product Price Quantity<BR><BR>prod1 £6.99 1<BR>prod2 £5.99 2<BR> <BR>Postage £0.50<BR><BR> Total whatever..I&#039;m lazy<BR><BR>Formatting would be a little different (just spacing out the prod table a little more.<BR><BR>Any ideas or links to scripts that do this?. I&#039;ve been looking for a while now but have had no luck in finding a solution. I just want to send a text email (and not html). <BR><BR>The other thing is that on the last page but one, this shopping basket is displayed. Is there anyway I could capture the html data from that page, store it in a session variable and then generate the email after the order has been completed (so sort of like sending a mirror of that page)? In that case having a HTML formatted email would be ok.<BR><BR><BR>Many thanks,<BR><BR>Richard Pain

  2. #2
    Join Date
    Dec 1969

    Default Pad the strings..

    .. with spaces:<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Did you ever come to the right place...

    Howdy Richard,<BR><BR>Boy, oh boy, did you ever luck out. Years back I was doing the same thing in JSP, and wrote a java class to do that. I found it so handy I ported it to JavaScript as well. It&#039;s pretty powerful, exactly what you are looking for and then some. I dug through the backups and found it.<BR><BR>It pads for you, you can horizontally and vertically align cells, specify the cell width, etc. It can wrap columns for you while maintaining the integrity with every row. You can even nest tables. You can use it server side (where you probably will) or client side.<BR><BR>Here is some output, using your data. The code to generate it follows.<BR><BR>Product Price Qty <BR>-------------------------------------------------- ------- -----<BR>prod1 £6.99 1<BR>prod2 £5.99 2<BR>Postage £0.50<BR>-------------------------------------------------- -------<BR> Total whateve<BR> r..I&#039;m<BR> lazy<BR><BR><BR>================================== ===========<BR><BR>&#060;script language="javascript" src=""&#062;&#060;/script&#062;<BR>&#060;html&#062;<BR>&#060;body&#06 2;<BR>&#060;pre&#062;<BR>&#060;script&#062;<BR>var tt=new TextTable();<BR>var r=0;<BR>tt.set(0,r,"Product",50);<BR>tt.set(1,r,"P rice",7,TextTable.ALIGN.CENTER);<BR>tt.set(2,r,"Qt y",5,TextTable.ALIGN.CENTER);<BR>r++;<BR>tt.set(0, r,"--------------------------------------------------");<BR>tt.set(1,r,"-------");<BR>tt.set(2,r,"-----");<BR>r++;<BR>tt.set(0,r,"prod1",50);<BR>tt.set(1 ,r,"£6.99",7,TextTable.ALIGN.RIGHT);<BR>tt.set(2, r,"1",5,TextTable.ALIGN.RIGHT);<BR>r++;<BR>tt.set( 0,r,"prod2",50);<BR>tt.set(1,r,"£5.99",7,TextTabl e.ALIGN.RIGHT);<BR>tt.set(2,r,"2",5,TextTable.ALIG N.RIGHT);<BR>r++;<BR>tt.set(0,r,"Postage",50);<BR> tt.set(1,r,"£0.50",7,TextTable.ALIGN.RIGHT);<BR>r ++;<BR>tt.set(0,r,"--------------------------------------------------");<BR>tt.set(1,r,"-------");<BR>r++;<BR>tt.set(0,r,"Total",50,TextTable.ALI GN.RIGHT);<BR>tt.set(1,r,"whatever..I&#039;m lazy",7,TextTable.ALIGN.RIGHT);<BR><BR>document.wr ite(tt);<BR>&#060;/script&#062;<BR>&#060;/pre&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR><BR>==================<BR><BR>To use it serverside, enclose the code in<BR>&#060;script language="javascript" runat="server"&#062;&#060;/script&#062;<BR>tags and include the file. If you are using VBScript, use TextTable.create() instead of new TextTable().<BR><BR>The trick to remember is that every row is independent, you will have so specify column widths on each row.<BR><BR>I&#039;m using this same blurb as documentation at:<BR><BR><BR>I don&#039;t remember the state of the code, but think it&#039;s pretty stable. If you have problems, let me know.<BR><BR>Cheers,<BR>Scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts