R
radio
I have a list box populated with some groups. All groups have a list
of related offices; I have these in the following xml format:
<Location>My Group 1</Location>
<Location Group="My Group 1">Office 1</Location>
<Location Group="My Group 1">Office 2</Location>
<Location>My Group 2</Location>
<Location Group="My Group 2">Office 1</Location>
<Location Group="My Group 2">Office 2</Location>
I have the following select box:
<select name="audienceLocation" size="6" multiple
onChange="tellGroup(this.options[selectedIndex].text);" >
</select>
Which calls the below function and finds a match with <Location> and
the Group element. So effectively if you click My Group 1, all of the
offices that are associated with My Group 1 are also selected.
function tellGroup(name)
{
var elements = (controlledVocabXml.documentElement.getElementsByTagName("Location"));
var audienceUnencoded = "";
for (j=0;j<[elements.length];j++)
{
var audienceElements = (elements[j].Group);
var audienceRegExp = new RegExp(audienceElements + "(,|$)+");
if (name.match(audienceRegExp) != null)
{document.theForm.audienceLocation.options[j].selected = true; }
}
}
This works, however, the problem I'm having is if the Ctrl key is held
while selecting another group (so the users can select multiple
groups) the function doesn't seem to work on the newly selected group.
I'm restricted to DOM level 1 as I'm writing code that has to work in
Dreamweaver's API.
Any help much appreciated
of related offices; I have these in the following xml format:
<Location>My Group 1</Location>
<Location Group="My Group 1">Office 1</Location>
<Location Group="My Group 1">Office 2</Location>
<Location>My Group 2</Location>
<Location Group="My Group 2">Office 1</Location>
<Location Group="My Group 2">Office 2</Location>
I have the following select box:
<select name="audienceLocation" size="6" multiple
onChange="tellGroup(this.options[selectedIndex].text);" >
</select>
Which calls the below function and finds a match with <Location> and
the Group element. So effectively if you click My Group 1, all of the
offices that are associated with My Group 1 are also selected.
function tellGroup(name)
{
var elements = (controlledVocabXml.documentElement.getElementsByTagName("Location"));
var audienceUnencoded = "";
for (j=0;j<[elements.length];j++)
{
var audienceElements = (elements[j].Group);
var audienceRegExp = new RegExp(audienceElements + "(,|$)+");
if (name.match(audienceRegExp) != null)
{document.theForm.audienceLocation.options[j].selected = true; }
}
}
This works, however, the problem I'm having is if the Ctrl key is held
while selecting another group (so the users can select multiple
groups) the function doesn't seem to work on the newly selected group.
I'm restricted to DOM level 1 as I'm writing code that has to work in
Dreamweaver's API.
Any help much appreciated