unable to execute statements in sequential order while calling one function from another function in javascript
<p>while designing my webpage, i have done with some javascript validations, in JS file, i'm trying to call one function from another function. The first is called when i click on button. In first function, i'm trying to set text for label and then i called the second function, but the second function is called first and then the text is set for label. The sequence is missing. I don't know, why the statements are not executed in sequence...If anyone know, please tell me the solution.</p>

<pre><code>&lt;script&gt;
    function first(){
        labelValue = document.getElementById("getlabel");
        labelValue.innerHTML = "FirstText";
        second();
    }
    function second(){
        labelValue.text = "secondText";
    }
</code></pre>

<p>Here, i can't set text for 'labelValue' i.e., "FirstText" before second() is called. It was set after second() is called.</p>

<pre><code>function first(){
    labelValue = document.getElementById("getlabel");
    labelValue.innerHTML = "FirstText";
    image = document.getElementById("getImage");
    image.src = "hello.jpg";
    second();  
}
function second(){
    labelValue.innerHTML = "SecondText";
    label1 = document.getElementById("name");
    label1.innerHTML =  "sarah";
}
</code></pre>

<p>first it sets value for 'name' label and then it sets image 'hello.jpg' for 'image' and the text 'FirstText' for label 'labelValue'.        </p>
