Alpha Video Training
Results 1 to 15 of 15

Thread: Variable In Html

  1. #1
    Member
    Real Name
    Alan Lee
    Join Date
    Jul 2000
    Location
    Olive Branch, MS
    Posts
    198

    Default Variable In Html

    I am using HTML in a dialog message box for a desk top application and would like to insert a variable in the message body. I cannot seem to figure it out.

    Thanks!

  2. #2
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Re: Variable In Html

    Try something in this form:
    "blah, blah "+var->v_your variable+" some more blah."

    Raymond Lyons

  3. #3
    Member
    Real Name
    Alan Lee
    Join Date
    Jul 2000
    Location
    Olive Branch, MS
    Posts
    198

    Default Re: Variable In Html

    Nope. It displays the +var->x as text.

  4. #4
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Re: Variable In Html

    First, I am no expert at this, so take what I say with a grain of salt.
    Second, I think even people with more expertise need more from you about the context and details of what you are trying to do, such as a sample database to work with.

    With that in mind, the following probably very crude code displays both field data and data contained in a variable when I stick it into an HTML memo field and/or when I send it as a message body in an email. Note the sent to "+var->v_email_to+".<br><br>" part, which is the variable and note that it is has quotation marks at each end (same goes for the fields B_F_Name, B_L_Name Ln_Off and Title).

    Code:
    email_ed.text= "<html><head> </head><body><div><P align=left\" class=style__1\"><p><FONT face=\"Tahoma\" style=\"font-size:10pt;color:#0000ff\"><br><br>The attached PDF file is for "+B_F_Name-" "+B_L_Name+" is being sent to "+var->v_email_to+".<br><br>"+Ln_off+"<br>"+title+"</p></div></body></body></html>"
    Maybe studying this a bit will help. If not, somebody else will have to help unless you upload a sample database with what you are trying to do.

    Raymond Lyons

  5. #5
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Variable In Html

    Quote Originally Posted by Alan Lee View Post
    Nope. It displays the +var->x as text.
    Yep.. it will display it as text.. that is until you evaluate it.
    Now you know what to do!

  6. #6
    Member mariusm's Avatar
    Real Name
    Marius M.
    Join Date
    Sep 2006
    Location
    Plymouth, UK
    Posts
    199

    Default Re: Variable In Html

    Yup; evaluate_string() will do what you need.
    It is easier to get older than wiser

  7. #7
    "Certified" Alphaholic
    Real Name
    Raymond Lyons
    Join Date
    Apr 2000
    Location
    Carlsbad, CA
    Posts
    2,143

    Default Re: Variable In Html

    Quote Originally Posted by mariusm View Post
    Yup; evaluate_string() will do what you need.
    Yes, but knowing the context, as I stated earlier, would help because some contexts, such as the two I mentioned [sticking my sample code into an HTML memo field and/or sending it as a message body in at least some A5 email functions] automatically handles the evaluation without using things like evaluate_string(). In this case, Alan stated "I am using HTML in a dialog message box." In that case, assuming the message box is somewhere where the variable and fields exist (e.g., on a form), the evaluation is automatic--at least it is in my testing.

    Raymond Lyons

  8. #8
    Member
    Real Name
    John P.
    Join Date
    Nov 2010
    Location
    Boston, MA
    Posts
    328

    Default Re: Variable In Html

    OP was there a solution? I'm running into the same issue on my project. I'd like to display "PO Number:" +PO_Number but i'm not having any luck coding the html using evaluate_string().

    Could someone post some sample html for reference?

    Here is what I have, PO_number is supposed to reference to my field:

    dialog.jpg

    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor">
    <title></title>
    <style>
    <!--
    p { margin-top: 0; margin-bottom: 0 }
    -->
    </style>
    </head>
    <body>
    <p>PO Number: +PO_number</p></body></html>

  9. #9
    Member
    Real Name
    John P.
    Join Date
    Nov 2010
    Location
    Boston, MA
    Posts
    328

    Default Re: Variable In Html

    Any suggestions on how to display my PO_number field in html?

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Variable In Html

    Not clear on what you're doing. Xdialog? If so HTML text or HTML form? Or something else?
    There can be only one.

  11. #11
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Variable In Html

    Try this.

    Code:
    dim global ht as C
    dim po_number as C
    po_number = "ABC123"
    
    ht = <<%strc%
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor">
    <title></title>
    <style>
    <!--
    p { margin-top: 0; margin-bottom: 0 }
    -->
    </style>
    </head>
    <body>
    <p>PO Number: +PO_number</p></body></html>
    %strc%
    
    ht = strtran(ht,"+PO_number",var->po_number)
    
    'Create an XDialog dialog box to prompt for parameters.
    DIM tst as P
    dim tst.object as p 
    dim tst.class as c
    tst.class = "dhtmledit.dhtmledit"
    DIM SHARED varC_result as C
    DIM tst_html as c 
    tst_html = var->ht
    'Force the background color of the html text to be Win3D so that it blends in with the Xdialog box.
    dim win3dcolor as c 
    win3dcolor = ui_color_format("win3d","#rhghbh")
    
    tst_html = a5_html_background(tst_html,win3dcolor)
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Alpha Five",<<%dlg%
    {startup=init}
    {region}
    | {activex=40,5tst?.f.};
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%,<<%code%
    if a_dlg_button = "init" then 
    	a_dlg_button = ""
    	tst.object.browsemode = .t. 
    	tst.object.appearance = 0
    	tst.object.ScrollBars = .f.
    	on error goto tst_error
    	tst.object.documenthtml = tst_html
    	on error goto 0
    	tst.object.Refresh()
    	a_dlg_button = ""
    
    end if
    end 
    
    tst_error:
    ui_msg_box("Error","Invalid URL or HTML content.",UI_STOP_SYMBOL)
    end
    %code%)
    There can be only one.

  12. #12
    Member
    Real Name
    John P.
    Join Date
    Nov 2010
    Location
    Boston, MA
    Posts
    328

    Default Re: Variable In Html

    Stan, its a pop-up dialog box with html text. Is it possible to use a more simple code in the source window, what is necessary to edit in order to Show the PO number as a variable/field value?
    dialog box.jpg

  13. #13
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Variable In Html

    You need to design the message box, capture the xbasic, then edit it.

    Example:

    Code:
    dim shared vpo_number as C
    vpo_number = "ABC123"
    
    'Displays a message box (style:'OK Button', image: 'No symbol', id: 'a').
    DIM SHARED  a_result as N
    DIM SHARED  a_OK_Button as L 
    a_OK_Button = .F.
    
    title_var = ""
    message_text_var = <<%text%
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor">
    <title></title>
    <style>
    <!--
    p { margin-top: 0; margin-bottom: 0 }
    -->
    </style>
    </head>
    <body>
    <p>PO Number: +PO_number</p></body></html> 
    %text%
    
    message_text_var = strtran(message_text_var,"+PO_number",vpo_number)
    
    a_result=ui_html_msg_box(title_var,message_text_var,UI_OK+ UI_FIRST_BUTTON_DEFAULT+ UI_NO_SYMBOL,2,1,.f.,.t.,"inches","inches","Win3D")
    'Test to see which button on the message box was pressed....
    SELECT
    	CASE a_result = UI_OK_SELECTED
    		a_OK_Button= .t.
    END SELECT
    The portions in red are what I added. In your case you wouldn't hard code the vpo_number in the code but would refer to the po_number available. If you are using this on a form where the po_number is an object on the form and the object name of the po_number field is po_number you could use

    message_text_var = strtran(message_text_var,"+PO_number",po_number.value)
    There can be only one.

  14. #14
    Member
    Real Name
    John P.
    Join Date
    Nov 2010
    Location
    Boston, MA
    Posts
    328

    Default Re: Variable In Html

    great, this makes sense. I was able to get it to work, but I wanted to change the size and alignment, when I did this the code stopped processing the strtran command. Here is what I have, the red is what was changed:

    Code:
    'Displays a message box (style:'OK Button', image: 'No symbol', id: 'a').
    DIM SHARED  a_result as N
    DIM SHARED  a_OK_Button as L 
    a_OK_Button = .F.
    
    title_var = "PO Stamp"
    message_text_var = <<%text%
    <html>
    <head>
    <meta name="generator" content="Alpha Five HTML Editor">
    <title></title>
    <style>
    <!--
    p            { margin-top: 0; margin-bottom: 0 }
    -->
    </style>
    </head>
    <body>
    <p align=center>PO Number </p>
    <p align=center><strong><font size=5>+PO_Number</font></strong></p></body></html>
    %text%
    
    message_text_var = strtran(message_text_var,"+PO_number",po_number.value)
    
    a_result=ui_html_msg_box(title_var,message_text_var,UI_OK+ UI_FIRST_BUTTON_DEFAULT+ UI_NO_SYMBOL,2,1,.f.,.t.,"inches","inches","Win3D")
    'Test to see which button on the message box was pressed....
    SELECT
    	CASE a_result = UI_OK_SELECTED
    		a_OK_Button= .t.
    END SELECT

  15. #15
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Variable In Html

    Strtran() is case sensitive. You also changed +PO_number to +PO_Number.

    Either change to stritran() or change the term to be replaced back to +PO_number.
    There can be only one.

Similar Threads

  1. Use variable in HTML Img src=
    By crimmelcp in forum Application Server Version 9 - Web/Browser Applications
    Replies: 4
    Last Post: 12-18-2016, 08:21 AM
  2. Get Session Variable Info To Reflects In A Heading Variable On A Report
    By Kobus Visser in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 11-12-2010, 10:52 AM
  3. Using HTML editor for simple HTML
    By Mr GreenJeans in forum Alpha Five Version 9 - Desktop Applications
    Replies: 11
    Last Post: 06-25-2010, 06:55 PM
  4. Combine HTML for Submit and HTML to go to target page
    By iviowa in forum Application Server Version 8
    Replies: 1
    Last Post: 10-07-2008, 02:45 PM

Bookmarks

Posting Permissions

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