Pad Option Values

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

    #1

    Pad Option Values

    Is it possible to use a function to pad option values in a drop down
    box? I need to pad 5 values in a drop down box 15 characters with balnk
    spaces then add a "1" on the end. Code example appreciated. Thanks
    Steve



    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Lasse Reichstein Nielsen

    #2
    Re: Pad Option Values

    Steve Bishop <steveb@viper.c om> writes:
    [color=blue]
    > Is it possible to use a function to pad option values in a drop down
    > box? I need to pad 5 values in a drop down box 15 characters with balnk
    > spaces then add a "1" on the end.[/color]

    By padding, do you mean padding to 15 characters or by 15 characters.
    I'll assume "to", as that is the (marginally) hardest.
    [color=blue]
    > Code example appreciated. Thanks[/color]

    ---
    function padSelect(selec tRef) {
    var options = selectRef.optio ns;
    for (var i=0; i<options.lengt h; i++) {
    var value = options[i].value;
    value += " ".substring(val ue.length) + "1";
    options[i].value = value;
    }
    }
    ---

    Call as:

    ---
    padSelect(docum ent.forms['formId'].elements['selectName']);
    ---

    (not tested)

    Good luck
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...