PrestwoodBoards Knowledgebase:

  From the October 2015 Issue of Prestwood eMag
JavaScript and AJAX:
Posted 10/19/2007 on 10/19/2007 and updated 6/18/2008
JavaScript Code Snippet:


Implements replaceAll in javascript. This is achieved using prototype.js

Syntax Example:

Add this between the head tags (replace [[ with < and ]] with >):

[[script type="text/javascript" src="prototype.js"]] [[/script]]

Here's the code (replace [[ with < and ]] with >):

[[script type="text/javascript"]]
// define your replace all function like this 
String.prototype.replaceAll=function(s1, s2) 
{return this.split(s1).join(s2)}; 
// use your replaceAll function like this
var replacedText = text2replace.replaceAll("-what to replace-",
		" -with what to replace- "); 
Code Contributed By bhavyait:
Visit Profile
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 9/28/2020