Worked it out :) like this:
function SelectedItems()
{
var lstMinor=document.getElementsByName("ListboxMinor")
var lstMajor=document.getElementsByName("ListboxMajor")
if ((lstMajor.length != 0)&&(lstMinor.length !=0)){
/* do nothing */
}
alert(lstMajor.length + " elements!")
}
Thinking about it a bit more, I think the issue is that in some cases the listbox referred to is present on the page and in others it is not.
How can JavaScript code detect the presence or absence of that listbox and either run the code or bypass it if the listbox is not on the page?
Thanks!
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...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.