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

dpacker_coors
dpacker_coors used Ask the Experts™
on
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");
Comment
Watch Question

Do more with

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

Here is a is sprintf

http://www.diveintojavascript.com/projects/javascript-sprintf

Author

Commented:
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.

-Dan
Michel PlungjanIT Expert
Top Expert 2009

Commented:
display="none"

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