From your comment is seems that you want to know when to use Javascript and when not to use Javascript.
That is a very subjective question. Personally, I think that you should not rely on javascript for functionality if you do not have a good reason to do so (for example performance concerns) because it restricts accessibility and is bad for SEO. See also these two posts.
Regarding your example: Nowadays, MVC is kind of a fussy term. But in option b, there is just one Javascript function, which handles everything. So you are not separating Model, View and Controller, so it cannot really be called MVC. And to which option is prefered: It is a matter of taste. I would prefer option a, because if you do want your website to be accessible, you would have to code a fallback for option b which seems like a lot of unnecessary work. The only downside is that you have an unnecessary extra request to the server.
And as to your second question: You do not integrate Javascript in php. Php is executed server-side (and then generally returns a generated html page to the user) while Javascript is executed client-side (and can for example change the html code that the user got).