Source language: Translate to:

Replacing variables on HTML page?

General questions about NeoBook

Moderator: Neosoft Support

Replacing variables on HTML page?

Postby stu » Wed Feb 17, 2016 8:02 am

Hi,

I'm working on a report maker that uses HTML files to display the reports... Now, I'm not entirely sure if I saw this on as a built in Neobook option or on a plugin... But, is there a way of having sort of:

Code: Select all
<table border="0" cellpadding="1" cellspacing="1" style="width:100%">
   <tbody>
      <tr>
         <td colspan="4">
         <h2>Personal Details</h2>
         </td>
      </tr>
      <tr>
         <td><strong>Surname</strong></td>
         <td>[DATABASE.tempPersonalDetails.Surname]</td>
         <td><strong>DoB</strong></td>
         <td>[DATABASE.tempPersonalDetails.DoB]</td>
      </tr>
      <tr>
         <td><strong>Forenames</strong></td>
         <td>[DATABASE.tempPersonalDetails.Forenames]</td>
         <td><strong>Gender</strong></td>
         <td>[DATABASE.tempPersonalDetails.Gender]</td>
      </tr>
      <tr>
         <td><strong>Address</strong></td>
         <td>[DATABASE.tempPersonalDetails.Address]</td>
         <td><strong>Height</strong></td>
         <td>[DATABASE.tempPersonalDetails.Height]</td>
      </tr>
      <tr>
         <td><strong>Occupation</strong></td>
         <td>[DATABASE.tempPersonalDetails.Occupation]</td>
         <td><strong>Email</strong></td>
         <td>[DATABASE.tempPersonalDetails.Email]</td>
      </tr>
   </tbody>
</table>


So you see I got a few variables stored in the HTML...

Data would come from a temporary table:

Code: Select all
dbpexecsql "DATABASE" "SELECT * FROM PersonalDetails WHERE UserID = 1" "tempPersonalDetails"


Is there a way to populate the variables sort of "on the fly"? Just before printing the report in this fashion:

Code: Select all
BrowserPrint "WebBrowser1" "PrintPreview"


Regards


BTW, I also thought of using BrowserLoadFromStr, just grab the (static) html from a file in the PubDir and then load the report on the WebBrowser, finally print. It works, I was just wondering if it would be better to do it th eother way.
User avatar
stu
 
Posts: 318
Joined: Wed Aug 07, 2013 11:37 am

Re: Replacing variables on HTML page?

Postby dpayer » Wed Feb 17, 2016 9:25 am

Have you tried using the NB action (under String Utilities) PopulateStr

It should evaluate variables and include them in any string (like your HTML string). Then put that string in the browser.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Replacing variables on HTML page?

Postby stu » Wed Feb 17, 2016 9:27 am

dpayer wrote:Have you tried using the NB action (under String Utilities) PopulateStr

It should evaluate variables and include them in any string (like your HTML string). Then put that string in the browser.


ahh! Yes, that is exactly what I saw, and I checked today but couldnt find... I'll see what alternative better suits my need.

Thanks!
User avatar
stu
 
Posts: 318
Joined: Wed Aug 07, 2013 11:37 am

Re: Replacing variables on HTML page?

Postby virger » Thu Feb 18, 2016 12:45 pm

Hola, lo intentaria con esto:
1) NeoPrg
2) Html
a) Tipo 1
b) Tipo 2

Adjunto esos elementos.
Debe asumir que la informacion es de su propia BASE de DATOS (yo lo implemente como variables)
HTML tipo #1
FileName== 'kkneo1.html'
Code: Select all
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>NEOBOOK-DATABASE</title>
</head>

<body>
<table border="0" cellpadding="1" cellspacing="1" style="width:100%">
   <tbody>
      <tr>
         <td colspan="4">
         <h2>Personal Details</h2>
         </td>
      </tr>
      <tr>
         <td id='1a'><strong>Surname</strong></td>
         <td id='11'>[DATABASE.tempPersonalDetails.Surname]</td>
         <td id='1b'><strong>DoB</strong></td>
         <td id='12'>[DATABASE.tempPersonalDetails.DoB]</td>
      </tr>
      <tr>
         <td id='2a' name='21'><strong>Forenames</strong></td>
         <td id='21'>[DATABASE.tempPersonalDetails.Forenames]</td>
         <td id='2b'><strong>Gender</strong></td>
         <td id='22'>[DATABASE.tempPersonalDetails.Gender]</td>
      </tr>
      <tr>
         <td id='3a'><strong>Address</strong></td>
         <td id='31'>[DATABASE.tempPersonalDetails.Address]</td>
         <td id='3b'><strong>Height</strong></td>
         <td id='32'>[DATABASE.tempPersonalDetails.Height]</td>
      </tr>
      <tr>
         <td id='4a'><strong>Occupation</strong></td>
         <td id='41'>[DATABASE.tempPersonalDetails.Occupation]</td>
         <td id='4b'><strong>Email</strong></td>
         <td id='42'>[DATABASE.tempPersonalDetails.Email]</td>
      </tr>
   </tbody>
</table>
<input type="hidden" name="dt" id="dt" value="">

</body>
</html>



HTML tipo #2
FileName== 'kkneo2.html'
Code: Select all
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>NEOBOOK-DATABASE</title>
</head>

<body>
<table border="0" cellpadding="1" cellspacing="1" style="width:100%">
   <tbody>
      <tr>
         <td colspan="4">
         <h2>Personal Details</h2>
         </td>
      </tr>
      <tr>
         <td id='1a'><strong>Surname</strong></td>
         <td id='Surname'>[DATABASE.tempPersonalDetails.Surname]</td>
         <td id='1b'><strong>DoB</strong></td>
         <td id='DoB'>[DATABASE.tempPersonalDetails.DoB]</td>
      </tr>
      <tr>
         <td id='2a' name='21'><strong>Forenames</strong></td>
         <td id='Forenames'>[DATABASE.tempPersonalDetails.Forenames]</td>
         <td id='2b'><strong>Gender</strong></td>
         <td id='Gender'>[DATABASE.tempPersonalDetails.Gender]</td>
      </tr>
      <tr>
         <td id='3a'><strong>Address</strong></td>
         <td id='Address'>[DATABASE.tempPersonalDetails.Address]</td>
         <td id='3b'><strong>Height</strong></td>
         <td id='Height'>[DATABASE.tempPersonalDetails.Height]</td>
      </tr>
      <tr>
         <td id='4a'><strong>Occupation</strong></td>
         <td id='Occupation'>[DATABASE.tempPersonalDetails.Occupation]</td>
         <td id='4b'><strong>Email</strong></td>
         <td id='Email'>[DATABASE.tempPersonalDetails.Email]</td>
      </tr>
   </tbody>
</table>
<input  type="hidden" name="dt" id="dt" value="">

</body>
</html>



Y el 'PUB'
Code: Select all
NBW Publication Source File
(C)2014 NeoSoft Corp.
Title=Interaccion NeoBook-Html-DataBase
Language=US
NeoBookVer=5.80
ScreenColors=16777216
ScreenWidth=800
ScreenHeight=480
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
ShapeTransColor=536870912
SplashProps=3
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
ObjectType=14
Name=WebBrowser1
X=0
Y=0
W=800
H=290
Anchor=1
FileName=[UseHtml]
VarName=[WebBrowser1Status]
TitleVarName=[WebBrowser1Title]
URLVarName=[WebBrowser1Addr]
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12634360
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=3
Name=PushButton1
X=688
Y=302
W=104
H=38
Anchor=0
Text=Exe Tipo2
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[UseHtml]" "kkneo2.html"¶¶strparse "Surname.DoB.Forenames.Gender.Address.Height.Occupation.Email" "." "[Td]" "[NumTd]"¶¶SetVar "[DATABASE.tempPersonalDetails.Surname]" "El Dato Es..Surname"¶SetVar "[DATABASE.tempPersonalDetails.DoB]" "El Dato Es..DoB"¶SetVar "[DATABASE.tempPersonalDetails.Forenames]" "El Dato Es..Forenames"¶SetVar "[DATABASE.tempPersonalDetails.Gender]" "El Dato Es..Gender"¶SetVar "[DATABASE.tempPersonalDetails.Address]" "El Dato Es..Address"¶SetVar "[DATABASE.tempPersonalDetails.Height]" "El Dato Es..Height"¶SetVar "[DATABASE.tempPersonalDetails.Occupation]" "El Dato Es..Occupation"¶SetVar "[DATABASE.tempPersonalDetails.Email]" "El Dato Es..Email"¶¶loop "1" "[NumTd]" "[rc]"¶    BrowserSetElement "WebBrowser1" "dt" "[DATABASE.tempPersonalDetails.[Td[rc]]]"¶    BrowserExecScript "WebBrowser1" "var dt = document.getElementById('dt').value;|document.getElementById('[Td[rc]]').innerHTML = dt;" ""¶endloop
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=12
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=7
ObjectType=3
Name=PushButton4
X=618
Y=378
W=104
H=33
Anchor=0
Text=Change
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=BrowserSetElement "WebBrowser1" "dt" "[Tex]"¶BrowserExecScript "WebBrowser1" "var dt = document.getElementById('dt').value;|document.getElementById('[ElTd]').innerHTML = dt;" ""
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=12
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=11
Name=CmbCampos
X=618
Y=343
W=142
H=33
Anchor=0
Text=Surname¶DoB¶Forenames¶Gender¶Address¶Height¶Occupation¶Email
VarName=[ElTd]
VarType=0
XPTheme=Yes
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=9
ObjectType=3
Name=PushButton5
X=6
Y=302
W=104
H=38
Anchor=0
Text=Exe Tipo1
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[UseHtml]" "kkneo1.html"¶strparse "11,12,21,22,31,32,41,42" "," "[rc]" "[x]"¶¶SetVar "[DATABASE.tempPersonalDetails.11]" "De 'DATABASE' Surname"¶SetVar "[DATABASE.tempPersonalDetails.12]" "De 'DATABASE' DoB"¶SetVar "[DATABASE.tempPersonalDetails.21]" "De 'DATABASE' Forenames"¶SetVar "[DATABASE.tempPersonalDetails.22]" "De 'DATABASE' Gender"¶SetVar "[DATABASE.tempPersonalDetails.31]" "De 'DATABASE' Address"¶SetVar "[DATABASE.tempPersonalDetails.32]" "De 'DATABASE' Height"¶SetVar "[DATABASE.tempPersonalDetails.41]" "De 'DATABASE' Occupation"¶SetVar "[DATABASE.tempPersonalDetails.42]" "De 'DATABASE' Email"¶¶loop "1" "4" "[r]"¶    loop "1" "2" "[c]"¶        BrowserSetElement "WebBrowser1" "dt" "[DATABASE.tempPersonalDetails.[r][c]]"¶        BrowserExecScript "WebBrowser1" "var dt = document.getElementById('dt').value;|document.getElementById('[r][c]').innerHTML = dt;" ""¶    endloop¶endloop
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=12
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=5
ObjectType=3
Name=PushButton6
X=77
Y=378
W=104
H=33
Anchor=0
Text=Change
Align=2
ImageStyle=0
XPTheme=Yes
ObjAction=BrowserSetElement "WebBrowser1" "dt" "[Tex]"¶BrowserExecScript "WebBrowser1" "var dt = document.getElementById('dt').value;|document.getElementById('[vElTd]').innerHTML = dt;" ""
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=12
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=11
Name=CmbxNum
X=39
Y=343
W=142
H=33
Anchor=0
Text=Surname¶DoB¶Forenames¶Gender¶Address¶Height¶Occupation¶Email
VarName=[ElTd]
VarType=1
XPTheme=Yes
ObjAction=setvar "[vElTd]" "[rc[ElTd]]"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=6
ObjectType=7
Name=Line1
X1=400
Y1=294
X2=400
Y2=472
EndCaps=0
LineColor=0
LineWidth=3
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=10
ObjectType=9
Name=EnTex
X=239
Y=319
W=324
H=33
Anchor=0
VarName=[Tex]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=14743776
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=8



Bueno, me cuentas. En mis pruebas oki.
COSTA RICA
PURA VIDA
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 2 guests