Why doesn' t his work?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • harry

    #1

    Why doesn' t his work?

    Trying to set the background colour for individual drop down items using
    JS -

    ////////////////////////////////////////////////////////////////////////////
    //////////////////////
    var ctrl = getElementByID( 'busresid');

    ctrl.options[2].style="backgro und-color:#FF0000";
    ////////////////////////////////////////////////////////////////////////////
    //////////////////////

    in jsp page can set it no problem like -

    ////////////////////////////////////////////////////////////////////////////
    //////////////////////
    <select id='busresid''>
    <option style="backgrou nd-color:#FF0000"> Red</option>
    <option style="backgrou nd-color:#FFFF33 ">Amber</option>
    <option style="backgrou nd-color:#00FF00 ">Green</option>
    </select>

    ////////////////////////////////////////////////////////////////////////////
    //////////////////////

    any ideas?

    thanks

    harry


  • Dag Sunde

    #2
    Re: Why doesn' t his work?

    "harry" <a@abc.com> wrote in message
    news:5HYuc.1076 $Rk7.10178742@n ews-text.cableinet. net...[color=blue]
    > Trying to set the background colour for individual drop down items using
    > JS -
    >
    > var ctrl = getElementByID( 'busresid');
    >
    > ctrl.options[2].style="backgro und-color:#FF0000";
    >
    > in jsp page can set it no problem like -
    >
    > <select id='busresid''>
    > <option style="backgrou nd-color:#FF0000"> Red</option>
    > <option style="backgrou nd-color:#FFFF33 ">Amber</option>
    > <option style="backgrou nd-color:#00FF00 ">Green</option>
    > </select>
    >[/color]
    <snipped a zillion slashes />

    the style attribute of an element is not a text-node, but an object:

    ctrl.options[2].style.backgrou ndColor = "#ff0000";

    --
    Dag
    58°26'15.9" N 008°46'45.5" E


    Comment

    • harry

      #3
      Re: Why doesn' t his work?

      Thanks, works fine now!

      "Dag Sunde" <ds@orion.no-way> wrote in message
      news:NUYuc.8445 8$BD3.10651723@ juliett.dax.net ...[color=blue]
      > "harry" <a@abc.com> wrote in message
      > news:5HYuc.1076 $Rk7.10178742@n ews-text.cableinet. net...[color=green]
      > > Trying to set the background colour for individual drop down items using
      > > JS -
      > >
      > > var ctrl = getElementByID( 'busresid');
      > >
      > > ctrl.options[2].style="backgro und-color:#FF0000";
      > >
      > > in jsp page can set it no problem like -
      > >
      > > <select id='busresid''>
      > > <option style="backgrou nd-color:#FF0000"> Red</option>
      > > <option style="backgrou nd-color:#FFFF33 ">Amber</option>
      > > <option style="backgrou nd-color:#00FF00 ">Green</option>
      > > </select>
      > >[/color]
      > <snipped a zillion slashes />
      >
      > the style attribute of an element is not a text-node, but an object:
      >
      > ctrl.options[2].style.backgrou ndColor = "#ff0000";
      >
      > --
      > Dag
      > 58°26'15.9" N 008°46'45.5" E
      >
      >[/color]


      Comment

      Working...