Adding options to select on a PocketPC

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

    Adding options to select on a PocketPC

    Hello,

    I'm writing some dynamic forms code for running on a PocketPC (running Windows
    2003). There is to be a set of select menus, and choosing a particular option
    in one menu changes the options available in the next.

    In an ordinary select element I can change the text and value of the various
    options using

    document.forms['myform'].elements.mysel ect.options[i].text = 'foo'
    document.forms['myform'].elements.mysel ect.options[i].value = 'foo_value'

    but I can't change the length of the options array: options.length doesn't
    seem to accept assignment or the ++ operator (as I'm used to using for IE6 on
    a desktop machine), or the method add(). If I can't add (and remove) options
    I'll have to resort to a static number of options in the select, and just
    blank out the ones I don't want, which I can do but is a bit unmannerly. I'd
    appreciate it if anyone can help.

    --
    Robin Johnson
    http://www.robinjohnson.f9.co.uk - rj@[no-spam]robinjohnson.f9 .co.uk
    "The labours of men of genius, however erroneously directed, scarcely ever fail
    in contributing ultimately to the solid advantage of mankind." - Mary Shelley
  • Thomas 'PointedEars' Lahn

    #2
    Re: Adding options to select on a PocketPC

    Robin Johnson wrote:[color=blue]
    > In an ordinary select element I can change the text and value of the various
    > options using
    >
    > document.forms['myform'].elements.mysel ect.options[i].text = 'foo'
    > document.forms['myform'].elements.mysel ect.options[i].value = 'foo_value'
    >
    > but I can't change the length of the options array: options.length doesn't
    > seem to accept assignment or the ++ operator (as I'm used to using for IE6 on
    > a desktop machine), or the method add().[/color]

    var o = document.forms['myform'].elements['myselect'].options;
    o[o.length] = new Option("text", "value");

    works in all browsers (that implement DOM Level 0 as of NS/IE 3+).


    PointedEars

    Comment

    Working...