How to create Check Box and Select Tag

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

    #1

    How to create Check Box and Select Tag

    Hi there,

    I'm new programmer in JavaScript. Can any one help in creating a
    checkbox (by default selected) from JavaScript and creating Drop down
    box (<select> ... </select>) from Javascript.

    Thanks In Advance

  • Lasse Reichstein Nielsen

    #2
    Re: How to create Check Box and Select Tag

    Raghuram Banda <raghuram.banda @nokia.sify.net > writes:
    [color=blue]
    > I'm new programmer in JavaScript. Can any one help in creating a
    > checkbox (by default selected) from JavaScript[/color]

    var cb = document.create Element("input" ); // create input node
    cb.type = "checkbox"; // set type
    cb.name = "checkboxNa me"; // set name if necessary
    cb.checked = cb.defaultCheck ed = true; // make it checked now and by default

    formRef.appendC hild(cb); // add it to some form
    [color=blue]
    > and creating Drop down
    > box (<select> ... </select>) from Javascript.[/color]

    var se = document.create Element("select ");
    cb.name = "selectName ";
    se.options[0] = new Option("selecti on 1","value 1");
    se.options[1] = new Option("selecti on 2","value 2");
    se.options[2] = new Option("selecti on 3","value 3");
    se.options[3] = new Option("selecti on 4","value 4");

    formRef.appendC hild(se);

    Hope this helps.
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...