How would i lock a desired axis?

I would like to know how to lock an axis to keep an object from rotating on it. I am using JavaScript and I need the Z axis to be locked, due to the Z axis's value changing during the rotation of the X and Y axis's due to joystick I am new to Unity3D and scripting altogether but so far this is the only trouble i have came across. Thanks in advanced; Dylan Wright

You might have a look at either of these answers:

"How would I lock a desired axis"

"How to set a single axis rotation of a gameobject"

Take a look at this answer: http://answers.unity3d.com/questions/4011/how-do-i-lock-out-a-axis

I fixed it, for some reason when i duplicated the MouseLook Script before i must have left out something, if using the MouseLook script to control two different options with two different inputs just change this :

public class MouseLook : MonoBehaviour {

to something like this :

public class MouseLook2 : MonoBehaviour {

and it will work just fine. It did for me anyways. Thanks for the help though i figured it out on my own.