How can I insert some variables on html code?

hibrid0

Active Member
Licensed User
Longtime User
Hi guy I dont know where can I put this question,
I'm thinking on use an html editor with b4j and I need put some the html code, but I need to insert some variables extracted from a db.

Then I need to save the html generated by the user with tokens or something to mark where can I insert the variables.

but I dont know from where can I start.

Example on my mind.
//////////////////////////////////////////////
Table with 2 fields: ID, Name and last name.
Record 1: 1, Josh, Be.

//////////////////////////////////////////////
Html code:

<Title>Page for %%Name%%</title>
<body>This is an example what I want to know, but I dont understand right now from where can I do this %%Lastname%%</body>

//////////////////////////////////////////////

I need to save this html from a backend, then this will be generated from the user side.
And he need it call the html and show the page with names or others variables on it.

Help me, any light on the way is so good for me.
 

Descartex

Well-Known Member
Licensed User
Longtime User
Can you use PHP on your backend?
If yes, you can pass the values via POST and later show them on the PHP generated web.
Regards
 

Descartex

Well-Known Member
Licensed User
Longtime User
Other thing you can do is to store the whole HTML code on a string var and later replace the var for the value, such as:
B4X:
HTMLCode.Replace("%%Name%%",Name)
HTMLCode.Replace("%%LastName%%",LastName)
After this code, in HTMLCode you might have the right values.
 

hibrid0

Active Member
Licensed User
Longtime User
Hi and thanks for your quick answer, I want to use Bj4 in the backend and B4A on the mobile.
 

Descartex

Well-Known Member
Licensed User
Longtime User
Then, you might use the second option.
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
I would follow this steps.

1.- Look or wrap an HTML parser (JSOUP) OR an XML parser (XMLSax) and use a library to convert the HTML to XML (JTIDY)

2.- look for your character variables (may be like VB.net with an @)

3.- Create a new String with the the variables values.
 
Top