dynamicly add HTML++
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
dynamicly add HTML++
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
Harry
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
dynamicly add HTML++
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 ?
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
Harry
- Wai
- Moderator
- Posts: 165
- Joined: Wed Sep 12, 2007 9:04 am
- Location: Sandy, UK
- Contact:
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();
}
Hope that helps.
0 x
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
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).
<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
Harry
- Wai
- Moderator
- Posts: 165
- Joined: Wed Sep 12, 2007 9:04 am
- Location: Sandy, UK
- Contact:
You can get the column names from the table using:
[/code]
Code: Select all
var cols = rs.getMetaData();
var colcount = cols.columnCount;
for (var i = 1; i <= colcount; i++) {
// Build your meta tags
log(cols.getColumnName(i));
}
0 x
-
- Ebase User
- Posts: 118
- Joined: Tue Oct 23, 2012 7:01 am
- Location: The Netherlands
Who is online
Users browsing this forum: No registered users and 13 guests