Search these areas:
Support Forums
Product Info

DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Data Tables
Data Analysis
-JavaScript Language Reference
-The HotRAD Source Editor
-Working with Data Classes
-Building DataWeb Script Classes
-JavaScript Language Enhancements
-Handling Exceptions
-JavaScript Reserved Words
Object Model
Full-Text Search
Domain and Email Hosting
HotBlock Modules
Account Management
New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support

DataWeb User's Guide

JavaScript Language Enhancements
DataWeb script includes extensions to the scripting language that make it easier for you to perform common tasks in script, like outputting raw HTML to the browser, or constructing an email message.

Outputting HTML from Script

You can use the <ws:tags> element to output raw HTML from script, without escaping the HTML. HTML within the opening and closing tags <ws:tags> is output directly to the browser. For example, the following function writes some red text to the browser:
webcall function vermillion()
<font color="FF0000">vermillion</font>
Of course, you probably don't need to use script to output something so simple. It's more likely that you'll want to use script to perform some dynamic processing on the HTML before you write it to the browser. To include script within the element, you can use DataWeb's script-embedding syntax, which is similar to Microsoft's Active Server Pages (ASP) syntax. To use this syntax, embed script within <% %> tags. The following table demonstrates ways to use the script-embedding syntax:

Syntax Example Description
<% average("1,4,8,15") %> Executes the script within the tags. Does not output text to the browser.
<%= varX %> Writes a value to the browser.
<%+ strText %> Writes an HTML-encoded value to the browser. 
<%* strURL %> Writes a URL-encoded value to the browser.

For example, the following function uses the script-embedding syntax to determine whether a valid string has been passed in to the function before the text is written to the browser:
webcall function hello(name)
Hello, <%= (name != undefined) ? name : "world" %>.
The next example constructs an HTML table with the number of rows and columns specified when the function is called:

webcall function drawTable(rows, cols)
if (rows == 0) {rows = 1;}
if (cols == 0) {cols = 1;}

<table border="1" width="100%">

<% for(var i = 1; i <= rows; i++)
  <% for (var j = 1; j <= cols; j++)
    { %>
 <% } %>
Sending Email from Script

You can use the <ws:email> element to send email from script. Within the opening and closing <ws:email> tags, you can specify the fields to construct an Email object using a single text string. The valid email fields are described in the following table:

Field Description
From The sender's email address
To The recipient's email address
ReplyTo The reply to address for the current message
Subject The subject of the message
CC Carbon-copy recipients
BCC Blind carbon-copy recipients
ContentType Specifies the HTML content type for the current message. The default is "text/plain." For HTML-formatted content, use "text/html."
Body The body of the email message. Must be the last field specified. Can be more than one line. For example, the following function constructs an Email object, then calls the send() method to send it.

For example, the following function constructs an Email object, then calls the send() method to send it.
webcall function sendEmail()
  var e = <ws:email> 
           //one viable address syntax
           //another viable address syntax
    Subject:Very Important Message
    Body:I have a
      <%= <ws:tags>
      <i><font color="#FF0000">very</font></i>
      </ws:tags> %>
      important message for you.
      <br><br><font size=5>Thank you.</font>
Note that you can create an identical email by constructing a new Email object and setting its properties. Which syntax you use is a matter of personal preference.

In the previous example, the Body field includes the following embedded script, which in turn uses the <ws:tags> element to format the HTML before it is output:
<%= <ws:tags>
<i><font color="#FF0000">very</font></i>
</ws:tags> %>
This embedded script writes the word "very" in an italicized red font within the email body.
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
Email Us