Dealing with a dynamically populated div-based dropdown can be tricky, especially when it extends beyond the screen's limits and hides entries. This is an inherited application that lacks support, leaving me to handle it without the necessary expertise. I could really use some simple explanations here. Apologies for the information overload.
After scouring through Google and dissecting other parts of the code, I believe using an optionsCollection could resolve this specific issue. However, I am stuck on how to trigger a function to update other data when the selected value changes while using optionsCollection.
The complexity of the problem makes it impossible to share in its entirety. Therefore, I'll attempt to provide the relevant code snippets.
Here's where the trouble begins:
<div class="empform">
<html:form action="/processBlank">
<div id="divJobClass" style="visibility: hidden; position: absolute; height="50px"
border-color: #fff; border-style:solid; border-width: 1px; background: white; opacity: 1">
<table id="tableJobClass" cellspacing="0" style="border-color: #9090ff; border-style:solid; border-width:1px;" cellpadding="0"> <%
ctr = 0;
for (JobClassVO jc : jcList) { // href="setJC(<%=jc.getGuid()% >, '< %=jc.getJcIdDesc()% >')" %>
<tr><td><input style="border: none; background: white" type="text"
id="jc<%=ctr%>" size="50" value="<%=jc.getJcIdDesc()%>" readonly="readonly"
onclick="setJC(<%=jc.getGuid()%>, '<%=jc.getJcIdDesc()%>', <%=ctr%>)"
onkeydown='jcListCheck(event);'></td></tr><%
ctr++;
}
%>
This snippet demonstrates how the drop-down activates upon field click:
<td>
<html:hidden name="erfEmployee" property="jcGUIDString" indexed="true"/>
<html:text name="erfEmployee" property="jcId" indexed="true"
size="8" maxlength="25" onblur='<%= "isLastRow('JobClass', " + count + ");" %>'
onclick='<%= "showJcList(" + count + ");" %>'
onkeydown='<%= "jcCheck(event," + count + ");" %>'
onchange='<%= "verifyHoursClass(" + count + ");" %>' readonly="true" />
</td>
Functions like isLastRow, jcCheck, and onChange do not affect the appearance.
These functions are responsible for displaying the div:
function showJcList(index) {
var fld = elem("erfEmployee[" + index + "].erfEeSsnFormatted");
if (fld.value == "")
return;
var div = elem_("divJobClass");
jcGuidTarget = elem("erfEmployee["+index+"].jcGUIDString");
jcIdTarget = elem("erfEmployee["+index+"].jcId");
showList(jcIdTarget, div, jcGuidTarget);
focusSelected("jc", null, <%=jcList.size()-1%>);
}
function showList(idTarget, div, guidTarget) {
ddDiv = div;
if (ddDiv.style.visibility == "visible") {
ddDiv.style.visibility = "hidden";
return;
}
var iTop = 0, oNode = idTarget, iLeft = 0;
while(oNode.tagName != "BODY" && oNode.tagName != "HTML") {
iTop += oNode.offsetTop;
oNode = oNode.offsetParent;
}
oNode = idTarget;
while(oNode.tagName != "BODY" && oNode.tagName != "HTML") {
iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
ddDiv.style.left = "" + iLeft + "px";
ddDiv.style.top = "" + (iTop + idTarget.offsetHeight) + "px";
ddDiv.style.visibility = "visible";
ddIdTarget = idTarget;
ddGuidTarget = guidTarget;
}
Multiple online resources suggested using overflow:auto and setting a fixed size to tackle this issue, but this hasn't produced any visible changes. Perhaps my sizing arrangement was off. Though overflow:scroll added scroll bars, they only extended along with the overflowing div, exceeding the screen. I even debated calculating available space to adjust the div height accordingly, but that solution seems inelegant. Nevertheless, I'm open to suggestions, advice, or any innovative ideas. Thanks!