I just want to replace the tags with its available value.
But in a string may have multiple of same tags.
So i need to fetch and replace,
Array Sample :
var result = {
'[name]':'user_name',
'[age]':29
};
String :
<p id="text">
Hi [name], I really want to thank you.
You([name]), really done a great job.
user,
[name]-[age]
</p>
Javascript :
var text = document.getElementByID('text');
text.replace(string, value); // this replacement only helps first hit.
Here, i use "[name]" for 3 times, i have replacement value.
But i cant use ".replace()" function, because it wont work on second tag (if same).
Is it Possible ?
Or Any other Solution to Solve this ?
Thanks in Advance.