$HTML_Ouput .= preg_replace("'\[image\](.+?)\[\/image\]'is","<img \\1 align=middle style=\"margin:4px 4px;\">",ereg_replace(";"," ",$avalue));
JS will only execute once your PHP script has been parsed and the resultant HTML sent to the browser.
As such, a one to one translation is not possible.
However, if you could tell us what you are trying to do, then I'm sure a JS solution could be found.
Thanks, but I would prefer you help me out with my request.
Originally Posted by Pullo
Well, the thing is, you won't be able to translate that snippet one for one, drop it in your page and have it work.
That's not to say that what you are trying to achieve with PHP cannot be done with JS, but your snippet provides nowhere near enough context.
For example what do the variables $HTML_Ouput, $answers[$qid][$aid] and $avalue contain?
The best way for us to help you is if you describe what you are trying to do and provide some HTML and possibly JS for us to work with.
Also, a link to a page where we can see everything would be handy.
The problem is as follows:
how do I convert
<img src='http://www.url.com/pic.gif' height='10' width='15' align=middle style="margin:4px 4px;">
Something like this maybe?
var string = "[image]src='http://www.url.com/pic.gif';height='10';width='15'[/image]",
src = string.replace(/\[\/?image\]/g, "").replace(/;/g, " ");
newString = "<img " + src + "align=middle style=\"margin:4px 4px;\">"