Let $X$ and $Y$ be affine varieties such that the coordinate ring $A(Y)$ is a subring of $A(X)$. Let $$\pi:X\to Y$$ be the morphism induced by the inclusion $A(Y)\subseteq A(X)$. I need to show that $\pi$ is surjective if it satisfies the following condition:
If $J=(g_1,\ldots,g_n)\subseteq A(Y)$ is an ideal such that $J\cdot A(X)=A(X)$, then $J=A(Y)$.
I have a lot of trouble understanding how this condition can imply that $\pi$ is surjective. I don't know where to start. I start with "let $P\in Y$", but then what ideal $J$ do we take?