Web Component S_005DEPT: List Box

LANSA

Web Component S_005DEPT: List Box

<!-- Begin of LANSA for the WEB generated component. -->
<!-- Note the added parameter MULTIPLE onChange="BuildMultipleValues(this.form)" to the SELECT statement. -->
<!-- This will allow for multiple selections -->

<RDML CHECKVALUE="YES">
<SELECT SIZE=6 NAME="S_005DEPT" MULTIPLE onChange="BuildMultipleValues(this.form)">
<OPTION VALUE="ADM">ADMINISTRATION DPT
<OPTION VALUE="AUD">INTERNAL AUDITING
<OPTION VALUE="FLT">FLEET ADMINISTRATION
<OPTION VALUE="GAC">GROUP ACCOUNTS DEP
<OPTION VALUE="INF">INFORMATION SERVICES
<OPTION VALUE="LEG">LEGAL DEPARTMENT
<OPTION VALUE="MKT">MARKETING DEPARTMENT
<OPTION VALUE="R&D">RESEARCH & DEVELOP
<OPTION VALUE="TRVL">TRAVEL DEPARTMENT
</SELECT>
</RDML>

<!-- End of LANSA for the WEB generated component. -->

<!—Include Weblink component. -->

<BR><BR>

<RDML COMPONENT="S_005GETEMP">


<!-- Begin of added Java Script -->

<SCRIPT>

var MAX_ITEMS = <RDML MERGE="MAXITEMS">;

<!-- The JAVA SCRIPT function SetValues() is executed during the load of the HTML page via the onLoad parameter of the BODY tag. -->
<!-- By evaluating the incoming SELVALUES string containing the values selected when the page was sent down, it re-sets the -->
<!-- selected List Box entries -->

function SetValues()
{
var beginIndex = 0;
var endIndex = <RDML MERGE="MAXLENGTH">;
var currFieldValue = document.LANSA.ASELVALUES.value;
var y = 0;

if (document.LANSA.ASELVALUES.value != "")
{
for ( var x=0; x < MAX_ITEMS; x++)
{
var sellength = document.LANSA.ASELLENGTH.value;
var z = y + parseInt(sellength.substring(x, (x + 1)));
currValue = currFieldValue.substring(y, z);
y = y + endIndex;
for (var i=0; i < document.LANSA.LS_005DEPT.length; i++)
{
if (document.LANSA.LS_005DEPT.options[i].value == currValue)
{
document.LANSA.LS_005DEPT.options[i].selected = true;
}
}
}
}
}

<!-- The JAVA SCRIPT function BuildMultipleValues() processes all selected entries in the List Box and builds SELVALUES with -->
<!-- the values selected. Note that the List Box entry value will be padded out with blanks if its length is less than -->
<!-- MAXLENGTH. This will allow the RDML to redefine SELVALUES as an array of elements of the same length making it -->
<!-- very easy to process. In this example each of the List Box items returns the value of #DEPTMENT. -->
<!-- #DEPTMENT is an alphanumeric field with a length of 4. So, MAXLENGTH is set to 4 at the RDML level. However, -->
<!-- #DEPTMENT could be any value with a length less than 4. For example, if a user selects the Administration ('ADM') -->
<!-- and Internal Auditing ('AUD') departments whose codes are 3 characters long, after the execution of BuildMultipleValues, -->
<!-- SELVALUES will contain 'ADM AUD ' -->

function BuildMultipleValues(theform)
{

var counter = 0;
document.LANSA.ASELVALUES.value = "";
for(var i = 0; i < document.LANSA.LS_005DEPT.length; i++)
{

if ((document.LANSA.LS_005DEPT.options[i].selected == true))
{
counter++;
if (counter <= MAX_ITEMS)
{
var tempfield = document.LANSA.LS_005DEPT.options[i].value;
 for (var x = tempfield.length; x < <RDML MERGE="MAXLENGTH">; x++)
 {
  tempfield = tempfield + " ";
}

document.LANSA.ASELVALUES.value = document.LANSA.ASELVALUES.value +
      tempfield;
}
}
}
<!-- Alert Message if more than MAX_ITEMS are selected -->
if (counter > MAX_ITEMS)
{
alert("You have selected more than " + MAX_ITEMS +
  " options in this listbox. Only the first " + MAX_ITEMS + " entries will be used.");
}
}
</SCRIPT>