[thelist] Insert CSS class with JavaScript

Peter Abramowicz pabramow at web.net
Tue Dec 2 18:15:25 CST 2003


I wonder if anyone has done this or know how to do it.

Here is a problem, I am generating 'OPTION' tags with JavaScript, based on an info from MySQL database. 
I need to insert CSS class into the new tags. So far I wasn't able to came up with any way that works.
If anyone has any ideas I would really appreciate your input.

Peter Abramowicz
Web Developer

Here is a relevant bit of script:

regioninfo = new Array (new Array("prov_id", region_value, "Region Name" ), etc ;

function fillSelectFromArray(u_id, selectCtrl, itemArray ) {
 var i, j;
 if (itemArray != null) {
  // add new items
  for (i = 0; i < itemArray.length; i++) {
   if( itemArray[i][0] == u_id ) {
    selectCtrl.options[j] = new Option(itemArray[i][2]);
    selectCtrl.options[j].value = itemArray[i][1]; 
    echo (selectCtrl.options[j]);

function update_region( ) {
 var prov_id=this.document.search_condi.fm_prov.value;
 fillSelectFromArray( prov_id, this.document.search_condi.fm_region, regioninfo );

<select class="search" size="1" name="fm_prov" onchange="update_region()">
       <option class="search" value="none">-- Select Province </option>
    <option class="search" value="AB"  >Alberta</option>
    <option class="search" value="BC"  >British Columbia</option>

<select class="search" size="1" name="fm_region" id="fm_region">
       <option class="search" value="none">  Select   Region </option>
       <option class="search" value="map">  Regions Map </option>

More information about the thelist mailing list