perhaps a js function is worth a thousand words
This function will be placed on the <body onLoad="normalizeDDWidth();">
NOTE: Orginally, there is no parameters for the function, I recoded it.
But because, the getElementsByTagName("select") will get all the <select> from the screen including those under searchTable (which I don't want to have) and applies the 3mouse events and 14em style. In another words, all the <select> of ANY searchTable will NOT HAVE 'forOnMouseOver', 'forOnMouseOut', 'forOnBlur'. And the remaining <select> (not belong to any searchTable) will HAVE width either '14em' or 'auto', plus the 3 special created mouseEvent.
Hope it is clearly now ..
HTML Code:
function normalizeDDWidth(tableId, isSearchTable){
if(isSearchTable == false){
var a = document.getElementsByTagName("select");
for(var i=0; i<a.length; i++){
var selectObj = a[i];
var selectObjId = selectObj.id;
var selectedVal = selectObj.options[selectObj.selectedIndex].value;
if(selectedVal != ''){//&& this.offsetWidth <= 120
selectObj.style.width = "auto";
}
else{
selectObj.style.width = "14em";
}
selectObj.onmouseover = forOnMouseOver;
selectObj.onmouseout = forOnMouseOut;
selectObj.onblur = forOnBlur;
}//end for
}
else{//end isSearchTable == true, all DD's width & textfield are hardcoded here
var textFieldLen = "22";
if(tableId == "customersearchTbl"){
document.all.txtBrand.style.width = "14em";
document.all.txtServiceType.style.width = "19em";
document.all.txtCustomerClass.style.width = "19em";
document.all.txtTopSubIndicator.style.width = "19em";
}
else if(tableId == "txnsearchTbl"){
textFieldLen = "32";
document.all.brandId.style.width = "27em";
document.all.channel.style.width = "27em";
document.all.contactMode.style.width = "27em";
document.all.contactType.style.width = "27em";
document.all.txnGroup.style.width = "27em";
document.all.txnType.style.width = "27em";
document.all.customerClass.style.width = "16em";
document.all.topSubIndicator.style.width = "16em";
document.all.priority.style.width = "12em";
document.all.status.style.width = "12em";
}
else if(tableId == "massassignmentsearchTbl"){
textFieldLen = "32";
document.all.brand_id.style.width = "27em";
document.all.customerClass.style.width = "16em";
document.all.topSubIndicator.style.width = "16em";
document.all.channel.style.width = "27em";
document.all.contactMode.style.width = "27em";
document.all.contactType.style.width = "27em";
document.all.txnGroup.style.width = "27em";
document.all.txnType.style.width = "27em";
document.all.concernType.style.width = "27em";
document.all.assignedUserId.style.width = "29em";
document.all.priority.style.width = "29em";
}
else if(tableId == "bulkresolutionsearchTbl"){
textFieldLen = "32";
document.all.brand_id.style.width = "27em";
document.all.channel.style.width = "27em";
document.all.contactMode.style.width = "27em";
document.all.contactType.style.width = "27em";
document.all.txnGroup.style.width = "27em";
document.all.txnType.style.width = "27em";
document.all.concernType.style.width = "27em";
document.all.assignedUserId.style.width = "29em";
document.all.priority.style.width = "29em";
}
normalizeTextWidth(textFieldLen);
}
}//end normalizeDDWidth()
Bookmarks