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
-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

Script Library

  Convert Text to HTML
 
  chubbard posted this script:
  // TextToHTML
// takes a string an encodes it as html, then replaces all
// the cr/lf's with <br /> tags

public function TextToHTML(strIn)
  {
  var s = response.encodeHTML(strIn);
  var rgstr = s.split("\r\n");
  var strOut ="";
  for (var i = 0; i < rgstr.length; i++)
    {
    strOut += rgstr[i] + "<br />\r\n";
    }
  return strOut;
  }
 
  on 2001-03-25 18:28:30, chubbard responded:
  nice script. It's so useful, the response.encodeHTML method will do this for you if you set "format html" flag to true:

public function TextToHTML( strIn )
{
  return response.encodeHTML( strIn, true )
}
 
  on 2001-04-03 17:54:50, chubbard responded:
  If you'd like to simply format data output directly as html, steal this snip of code from georgesn's original suggestion:

public function formatHTML(strIn)
{
  var aRgstr = strIn.split( "\r\n" );
  var strOut ="";
  for (var i = 0; i < rgstr.length; i++)
    {
    strOut += rgstr[i] + "<br />\r\n";
    }
  return strOut;
}
 
  on 2001-04-20 20:21:30, chubbard responded:
  from http://support.westside.com/support/scriptLib/sDetails.view?rowid=22 here's a simpler way to do search and replace.


Function FindAndReplace(theString, searchString, replaceString)
{
return theString.split(searchString).join(replaceString);
}

in this case

strOut = FindAndReplace(strIn, "\r\n", "<br>\r\n");
 
  on 2001-08-27 15:23:29, chubbard responded:
  This is obsolete as response.encodeHTML() support replacing \r\n with <br>.  
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