I'm not a big fan of mixing js in server side script. But this can be arguable.