New to Unity 3d. GUI Button Help Needed Please..

Initially, I have a Textbox with some text and a Button. Each time I click the button, the text should change. Please help me how to do this in Unity.

function OnGUI () {

    GUI.Label(Rect (150,50,500,100), "During Solar Eclipse, the Moon passes between the Sun and the Earth");

    if (GUI.Button (Rect (10,70, 100, 20), "Next")) {
      displayText();    
    }       

}

function displayText(){
     print("Inside fucntion");
     GUI.Box(Rect (70,70,500,100), "Please print something");

    }

My problem is that, when I click on NEXT button, the control is going inside the displayText() function. It is also displaying "Inside Function". But the GUI Box is not displayed. Please help.

OnGUI() is a function that's called (almost) every single frame. So when your button is being pressed, it's only drawing your GUI.Box for one single frame, most likely invisible to the naked eye.

Instead, what you probably want to do, is have the Box inside of OnGUI() with some sort of condition on it so that it only draws when you want it to. You can also set the text it draws, too.

// PSEUDOCODE
bool pressed
string text

function OnGUI()
   GUI.Label
   if GUI.Button then
      pressed = true
      string = "Whatever you want"
   end if
   if pressed then
      GUI.Box(string)
   end if
end function

This pseudocode is how you could set up your GUI to potentially do what you want.

Also, next time be sure to code-format your pasted code by clicking the code button in the toolbar or surrounding the code with

...
tags.

var pressed = false;
var text = "";
var count = 0;
function OnGUI() 
{

    GUI.backgroundColor = Color.yellow;

    if(!pressed && count == 0) {
        GUI.Label(Rect(400,300,500,100)," The Solar Eclipse - During Solar Eclipse, the Moon passes between the Sun and the Earth.");
    }  

    if(GUI.Button(Rect (900,350,100,25),"Next")){
        pressed = true;
        count = count+1;
    }
    if(pressed && count == 1){
          text = "The Eclipse begins - The Moon starts to block the light from the Sun.";
          GUI.Box(Rect(400,300,500,100),text);

    }
    if(pressed && count == 2){
          text = "Eclipse Path - The Moon moves directly between the Earth and the Sun.";
          GUI.Box(Rect(400,300,500,100),text);

    }
     if(pressed && count == 3){
          text = "The Sun Reappears - As the Earth rotates, it spins out of the Moon's shadow.";
          GUI.Box(Rect(400,300,500,100),text);

    }
     if(pressed && count == 4){
          text = "The Eclipse is Over - The Moon moves away and the Eclipse is over.";
          GUI.Box(Rect(400,300,500,100),text);
          Destroy(gameObject);
    }

}

Below is the code based on the pseudocode. Thanks Spike.

var a1 : boolean = false;
function OnGUI () {
GUI.Label(Rect (150,50,500,100), "During Solar Eclipse, the Moon passes between the    Sun and the Earth");

if (GUI.Button (Rect (10,70, 100, 20), "Next"))
 {
displayText();  
 }  
 if(a1 == true)
 {
  GUI.Box(Rect (70,70,500,100), "Please print something");
 } 
 }

function displayText()
 {
 print("Inside fucntion");
 a1 = true;
 }