business intelligence - Cognos 8 Javascript to select values in a multi select list box prompt -
i have multi select list box value prompt in cognos 8.3.
contains values:
adelaide north
adelaide south
adelaide east
adelaide east
sydney north
sydney south
sydney east
sydney west
etc.
i want able add button onto prompt page when clicked, selects predetermined options, such adelaide north, south east , west.
for example: adelaide button select adelaide north, adelaide south, adelaide east , adelaide west, instead of making user select 4 choices in multi-select list box.
is there way can this? have named list box cbofsa in miscellaneous area of properties.
any appreciated.
i'm assuming web-based cognos interface? if so, should you:
if name cbofsa assigned id attribute of <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 adelaide" onclick="selectcity('adelaide', 'cbofsa');"> <input type="button" value="select 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)) { (var ii = 0, iilen = sel.length; ii < iilen; ++ii) { sel[ii].selected = (sel[ii].text.tolowercase().indexof(city) !== -1); } } } } } </script>
if name cbofsa assigned name attribute of <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 adelaide" onclick="selectcity('adelaide', 'cbofsa', this);"> <input type="button" value="select 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)) { (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 browser figure out whether cognos assigns value specify id or name attribute.
Comments
Post a Comment