updated js code snippets to PHP