I'm assuming this is a web-based Cognos interface? If so, this should do it for you:
If the name cboFSA is assigned as the ID attribute of the <select>
use:
<select size="6" id="cboFSA" multiple="multiple">
<option>Adelaide North</option>
<option>Adelaide South</option>
<option>Adelaide East</option>
<option>Adelaide East</option>
<option>Sydney North</option>
<option>Sydney South</option>
<option>Sydney East</option>
<option>Sydney West</option>
</select>
<input type="button" value="Select all Adelaide" onclick="selectCity('adelaide', 'cboFSA');">
<input type="button" value="Select all Sydney" onclick="selectCity('sydney', 'cboFSA');">
<script type="text/javascript">
function selectCity(city, list) {
if ('string' === typeof city) {
city = city.toLowerCase();
if (document.getElementById) {
var sel = document.getElementById(list);
if (sel && (sel = sel.options)) {
for (var ii = 0, iiLen = sel.length; ii < iiLen; ++ii) {
sel[ii].selected = (sel[ii].text.toLowerCase().indexOf(city) !== -1);
}
}
}
}
}
</script>
If the name cboFSA is assigned as the NAME attribute of the <select>
use:
<select size="6" name="cboFSA" multiple="multiple">
<option>Adelaide North</option>
<option>Adelaide South</option>
<option>Adelaide East</option>
<option>Adelaide East</option>
<option>Sydney North</option>
<option>Sydney South</option>
<option>Sydney East</option>
<option>Sydney West</option>
</select>
<input type="button" value="Select all Adelaide" onclick="selectCity('adelaide', 'cboFSA', this);">
<input type="button" value="Select all Sydney" onclick="selectCity('sydney', 'cboFSA', this);">
<script type="text/javascript">
function selectCity(city, list, btn) {
if ('string' === typeof city) {
city = city.toLowerCase();
var sel;
if (btn && btn.form && (sel = btn.form[list]) && (sel = sel.options)) {
for (var ii = 0, iiLen = sel.length; ii < iiLen; ++ii) {
sel[ii].selected = (sel[ii].text.toLowerCase().indexOf(city) !== -1);
}
}
}
}
</script>
You can use View > Source in your browser to figure out whether Cognos assigns the value you specify as the ID or NAME attribute.
Grant Wagner
2008-10-02 22:16:41