dynamicly add HTML++

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

dynamicly add HTML++

#1

Postby HarryDeBoer » Thu Oct 03, 2013 11:01 am

Can one programmaticly add HTML++ to a Form? I want to add some metatags to a form dynamicly in a onbefore form event.
0 x
Kind regards,

Harry

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Thu Oct 03, 2013 12:45 pm

Yes, you can include form field values in HTML++ e.g. &&MY_FIELD.
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

dynamicly add HTML++

#3

Postby HarryDeBoer » Wed Oct 09, 2013 6:40 am

If I want to do this dynamicly what's the right way to do this if I want to read columns of a ms sql database table where each column has to be a metatag:

1) set up the connection
2) use that connection in code
var con = system.getDatabaseConnection("MYCONN");
var stmt = con.prepareStatement("select TOP 1 * from MYTBL");
var rs = stmt.executeQuery();
3) iterate through the columns and fill FIELD_META
4) in the HTML++ section add '&&FIELD_META'

-Is this the correct way?
-How exactly do I code point 3. Could you give an example ?
0 x
Kind regards,

Harry

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#4

Postby Wai » Wed Oct 09, 2013 8:29 am

Code: Select all

var con = system.getDatabaseConnection("MYCONN"); 
var stmt; 
var rs; 

try {
	stmt = con.prepareStatement("select TOP 1 * from MYTBL");
	
	rs = stmt.executeQuery();

	while (rs.next()){
                if(fields.FIELD_META.value){
                        fields.FIELD_META.value = fields.FIELD_META.value + rs.getString("FIELD_META");
                }
                else{
		        fields.FIELD_META.value = rs.getString("FIELD_META");
                }
	}
} 
catch(err) {
	event.owner.addErrorMessage("Some error message");
}
finally {
	if (rs) rs.close(); 
	if (stmt) stmt. close; 
	if (con) con.close();
}
This is assuming that the column in your DB contains the whole HTML contents from the meta tag.

Hope that helps.
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#5

Postby HarryDeBoer » Wed Oct 09, 2013 10:06 am

I guess I was not clear enough, sorry for that. E.g. If I have a table with the columns ID, Name, ZIP, etc. I want metatags this way:

<meta name="IS_ATTR_ID">
<meta name="IS_ATTR_Name">
<meta name="IS_ATTR_ZIP">
..

So without knowing the table columns in front, I want to add metatags dynamicly for each column in the table (with a prefix).
0 x
Kind regards,

Harry

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#6

Postby Wai » Wed Oct 09, 2013 10:30 am

You can get the column names from the table using:

Code: Select all

var cols = rs.getMetaData&#40;&#41;; 
var colcount = cols.columnCount;

for &#40;var i = 1; i <= colcount; i++&#41; &#123;

  // Build your meta tags

  log&#40;cols.getColumnName&#40;i&#41;&#41;;
&#125;
[/code]
0 x

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

#7

Postby HarryDeBoer » Wed Oct 09, 2013 11:45 am

Thanks Wai, working fine now.[/code]
0 x
Kind regards,

Harry


Who is online

Users browsing this forum: No registered users and 13 guests