How to create Check Box and Select Tag

Discussion in 'Javascript' started by Raghuram Banda, Sep 11, 2003.

  1. 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
    Raghuram Banda, Sep 11, 2003
    #1
    1. Advertising

  2. Raghuram Banda <> writes:

    > I'm new programmer in JavaScript. Can any one help in creating a
    > checkbox (by default selected) from JavaScript


    var cb = document.createElement("input"); // create input node
    cb.type = "checkbox"; // set type
    cb.name = "checkboxName"; // set name if necessary
    cb.checked = cb.defaultChecked = true; // make it checked now and by default

    formRef.appendChild(cb); // add it to some form

    > and creating Drop down
    > box (<select> ... </select>) from Javascript.


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

    formRef.appendChild(se);

    Hope this helps.
    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Sep 11, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mit
    Replies:
    1
    Views:
    786
    Ramu Pulipati
    Jan 25, 2006
  2. shruds
    Replies:
    1
    Views:
    749
    John C. Bollinger
    Jan 27, 2006
  3. palmiere
    Replies:
    1
    Views:
    384
    Erwin Moller
    Feb 9, 2004
  4. Ferd Berfel
    Replies:
    4
    Views:
    143
  5. Jim

    Check box and text box disable

    Jim, Jun 3, 2004, in forum: Javascript
    Replies:
    3
    Views:
    107
    Randy Webb
    Jun 4, 2004
Loading...

Share This Page