Search these areas:
Help
Support Forums
Product Info



Introduction
DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Data Tables
Views
Templates
Components
Data Analysis
Members
Security
Importing
Exporting
FTP
JavaScript
-JavaScript Language Reference
-DataWeb
-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
Glossary
New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
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()
{
<ws:tags>
<font color="FF0000">vermillion</font>
</ws:tags>
}
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)
{
<ws:tags>
Hello, <%= (name != undefined) ? name : "world" %>.
</ws:tags>
}
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;}

<ws:tags>
<table border="1" width="100%">

<% for(var i = 1; i <= rows; i++)
{%>
  <tr>
  <% for (var j = 1; j <= cols; j++)
    { %>
    <td>&nbsp;</td>
 <% } %>
  </tr>
<%}%>
</table>
</ws:tags>
}
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>
    To:topdog@DataWeb.com 
           //one viable address syntax
    From:"LocalDog"<testacct@DataWeb.com>  
           //another viable address syntax
    Subject:Very Important Message
    Contenttype:text/html
    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>
    </ws:email>;
  e.send();
}
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    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us