I am calling the below function on the click of an 'OK' button to set the attribute of a cell of a table (attributes for <td> tag), however i am not able to set the 'style' attribute of the <td> tag with the code below. Please help me in achieving this.

function Ok()
{
variable ="FILTER:progid : DXImageTransform.Microsoft.gradient (GradientType=1, startColorstr="+GetE('txtColor1').value+", endColorstr="+GetE('txtColor2').value+"); HEIGHT:"+GetE('txtHeight').value+"px";  //setting the value of style attribute   
   for( i = 0 ; i < aCells.length ; i++ )
   {
       SetAttribute( aCells[i], 'borderColor'   , GetE('txtBorderColor').value ) ;
      SetAttribute( aCells[i], 'style'      , variable ) ; //not working
   }

   return true ;
}

The above code is to apply gradient color to the cell of a table.

{ SetAttribute( aCells[i], 'borderColor', GetE ('txtBorderColor').value ) ;
SetAttribute( aCells[i], 'style', variable ) ; //not working
} return true ;
}

it should besetAttribute() not SetAttribute()

it should besetAttribute() not SetAttribute()

I tried setAttribute(), it does not work and throws up an error saying object expected. SetAttribute() for other attributes works fine, but for 'style' attribute it does not work.

If you wil try my suggestion -- then the best reliable way to apply gradient colors to your cells is to use a simple mathematical equation with javascript.
Ok, as we go back to the "setAttribute" issue -- let's try this one 1st:

for( i = 0 ; i < aCells.length ; i++ )
{ aCells[i].setAttribute('borderColor', GetE ('txtBorderColor').value );
aCells[i].setAttribute('style', variable);
} //I havnt test your code, but i hope this can help.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.