Is it possible to pass parameters to replace text in a JavaScript

dpacker_coors used Ask the Experts™
Is there a way to dynamically replace text with JavaScript?  

An example in c# would be Console.WriteLine("{0}, the answer is {1}.", "Dan", "Forget it");
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Expert
Top Expert 2009
Wat do you mean by dynamic?
On load or on the server?

Here is a is sprintf


Thanks - sprintf provides exactly what I need.

I'm creating a hidden (style.visiblity = none) <div> on a web page that stores "generic" description information such as "The item is %f inches across and is colored %s".  When the user clicks on a product I want to show the <div> and display the appropriate item characteristics by replacing text.

Michel PlungjanIT Expert
Top Expert 2009


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial