Look at the forces in your system:
- In the y-direction, you have gravitation force.
- In the x-direction, there is no force.
Suppose you have vectors for the force and the displacement: $F=(F_x,F_y)$ and $d=(d_x,d_y)$, now to get the work W, you calculate the dot product* of these two:
$W=F*d=F_x*d_x + F_y*d_y$
$F_x=0$ (because there is no force on your ideal frictionless inclined plane) and
$F_y= -m*g$ (gravitational force; m=mass, g=gravitation constant=$9.87 m/s^2$)
above equation will give you:
$W=F_y*d_y = -m*g*d_y$.
So we see, since no force acts in the x-direction, no work is done in the x-direction.
*=in genereal this would be a line integral, but it boils down to the same idea.