Solved.
All i had to do was edit the xmlhttp.onreadystatechange part of the code.
so the corrected code should look like this.
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("TradeDetails").innerHTML = "";
document.getElementById("TradeDetails").innerHTML = xmlhttp.responseText;
**document.getElementById("txtTicketNo").value = document.getElementById("sub_tIDi").value;**
}
}
xmlhttp.open("GET", "NewTicket-AJAX-SubPage.asp?myMsg=" + myMsg, true);
xmlhttp.send();
and that solved all my problems.
was writing the right code all along but the challenge was to grasp the asynchronous nature of the code. when I move the code to the right section (i.e. xmlhttp.onreadystatechange) all was well.