I have some JavaScript which selects items from a listbox when a button is clicked. However, there could be times when there are not items at all in the listbox. How do I determine this so that the full JavaScript does not run if there are no items in the listbox?
Currently I have the following code shown below, but I don't want to assign anything to intCount if the listbox is empty. How do I go about that? - Thanks.
function SelectedItems(){
var intCount = window.document.myDataEntryForm.ListboxMinor.options.length;
var intCountC = window.document.myDataEntryForm.ListboxMajor.options.length;
if (intCount > 0){
for (i = 0; i < intCount; i++){
window.document.myDataEntryForm.ListboxMinor.options(i).selected = true;
}
}
if (intCountC > 0){
for (i = 0; i < intCountC; i++){
window.document.myDataEntryForm.ListboxMajor.options(i).selected = true;
}
}
}
Currently I have the following code shown below, but I don't want to assign anything to intCount if the listbox is empty. How do I go about that? - Thanks.
function SelectedItems(){
var intCount = window.document.myDataEntryForm.ListboxMinor.options.length;
var intCountC = window.document.myDataEntryForm.ListboxMajor.options.length;
if (intCount > 0){
for (i = 0; i < intCount; i++){
window.document.myDataEntryForm.ListboxMinor.options(i).selected = true;
}
}
if (intCountC > 0){
for (i = 0; i < intCountC; i++){
window.document.myDataEntryForm.ListboxMajor.options(i).selected = true;
}
}
}