I have the following three functions
function getFieldValue(fieldName) {
var myField = document.getElementById(fieldName);
callServlet(myField);
return myField.value; //doesn't wait
}
function callServlet(myField){
var url = '/EvaluationLibrary?settingField='+myField;
var myIframe = document.getElementById("myHiddenFrame");
myIframe.src="}
The function above basically loads the iframe with the servlets response html. The html returned by the servlet uses the onload attribute. Onload calls the third function:
<body onload=\"parent.setFieldValue('" + result + "','" + fieldName + "');\"/>"
function setFieldValue(result,fieldName){
var fieldToSet = document.getElementById(fieldName);
fieldToSet.value = result;
}
The problem is that in function getFieldValue returns an empty string because it doesn't wait for the servlet call to the iframe and then for the iframe to finish loading and then call the setFieldValue function to populate the field.
Any ideas on making getFieldValue wait for setFieldValue?
function getFieldValue(fieldName) {
var myField = document.getElementById(fieldName);
callServlet(myField);
return myField.value; //doesn't wait
}
function callServlet(myField){
var url = '/EvaluationLibrary?settingField='+myField;
var myIframe = document.getElementById("myHiddenFrame");
myIframe.src="}
The function above basically loads the iframe with the servlets response html. The html returned by the servlet uses the onload attribute. Onload calls the third function:
<body onload=\"parent.setFieldValue('" + result + "','" + fieldName + "');\"/>"
function setFieldValue(result,fieldName){
var fieldToSet = document.getElementById(fieldName);
fieldToSet.value = result;
}
The problem is that in function getFieldValue returns an empty string because it doesn't wait for the servlet call to the iframe and then for the iframe to finish loading and then call the setFieldValue function to populate the field.
Any ideas on making getFieldValue wait for setFieldValue?