Ok, here;s the step by step for my issue:
1. there are 2 drop downs (both are populated using iframes) & datasource.
2. 1st drop down is populated when page loads. Second drop down depends on first drop down's select value.
3. Tricky part here is, user selects first drop down by another method not just selecting from drop down. He selects those values from another button,that's when I call
selectRowDataForEdit method.. 2nd drop down populates after this method call.
all population occurs correctly but the 2nd drop down selected value is not set.
I think it's something to do with, iframe load occurs after javascript function is completed. hence it's not able to select the value when none is available.
It's little complicated. I guess an expert might see the issue immediately.
-
function parentUpdated(targetFieldName, parentFieldNames, parentParameterNames, dataSource) {
-
var url = "<c:url value="/dataset.do"/>?";
-
url += "dataSource=" + dataSource;
-
for (var i=0; i<parentFieldNames.length; i++) {
-
var field = document.getElementsByName(parentFieldNames[i]);
-
field = field[0];
-
if(field.value.length == 0) {
-
return;
-
}
-
url += "&" + escape(parentParameterNames[i]) + "=" + escape(field.value);
-
}
-
updateSelectBox(url, targetFieldName);
-
}
-
-
-
function selectRowDataForEdit(index,type){
-
// alert("rowId ="+index);
-
-
if(type == 'Payments'){
-
-
document.forms['paymentInformationForm'].elements['obligorNumberSelected'].value = document.forms['paymentInformationForm'].elements['payments['+index+'].obligorNumber'].value;
-
-
//alert("Selected value ="+document.forms['paymentInformationForm'].elements['obligorNumberSelected'].value);
-
parentUpdated("paymentInformation.obligationNumber", new Array("wdcuPackageId","obligorNumberSelected"), new Array("currentWDCUPackageID","selectedObligorNumber"), "com.comerica.wdcu.service.ObligationsDataSource");
-
-
alert("obligation no: "+document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value);
-
}
-
if(document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value != ''){
-
var theDayElement = document.forms['paymentInformationForm'].elements['paymentInformationForGuarantee.obligationNumber'];
-
var optionCounter;
-
for (optionCounter = 0; optionCounter < theDayElement.length; optionCounter++) {
-
alert("Option text is " + theDayElement.options[optionCounter].text)
-
alert(" and its value is "+theDayElement.options[optionCounter].value);
-
if(document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value == theDayElement.options[optionCounter].value){
-
alert("Inside...");
-
theDayElement.options[optionCounter].selected = true;
-
}
-
}
-
document.forms['paymentInformationForm'].elements['paymentInformation.obligationNumber'].value = document.forms['paymentInformationForm'].elements['obligationNumberSelected'].value;
-
alert("This time ="+document.forms['paymentInformationForm'].elements['paymentInformation.obligationNumber'].value);
-
}
-
}
-