document.getElementById('id') find out what type of element in javascript

Discussion in 'Javascript' started by Katie, Jul 20, 2006.

  1. Katie

    Katie Guest

    Hi

    I have a function which uses the document.getElementById('id') to
    change attributes of form objects etc. Is there any way i can find out
    if the element is a checkbox, textbox, radio button etc, because i want
    to distinguish between them in my function

    Thanks for ure time and help
    :)
    Katie, Jul 20, 2006
    #1
    1. Advertising

  2. Katie

    Matt Kruse Guest

    Katie wrote:
    > I have a function which uses the document.getElementById('id') to
    > change attributes of form objects etc. Is there any way i can find out
    > if the element is a checkbox, textbox, radio button etc, because i
    > want to distinguish between them in my function


    Check the "type" property, and javascript docs for what values to expect.

    --
    Matt Kruse
    http://www.JavascriptToolbox.com
    http://www.AjaxToolbox.com
    Matt Kruse, Jul 20, 2006
    #2
    1. Advertising

  3. Katie

    Randy Webb Guest

    Re: document.getElementById('id') find out what type of element injavascript

    Katie said the following on 7/20/2006 3:54 PM:
    > Hi
    >
    > I have a function which uses the document.getElementById('id') to
    > change attributes of form objects etc. Is there any way i can find out
    > if the element is a checkbox, textbox, radio button etc, because i want
    > to distinguish between them in my function


    document.getElementById('someDumbIDInsteadOfTheFormsCollection').type

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Jul 20, 2006
    #3
    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. Franck
    Replies:
    3
    Views:
    2,368
    Eliyahu Goldin
    Aug 25, 2005
  2. wk
    Replies:
    5
    Views:
    160
    Dietmar Meier
    Apr 22, 2005
  3. Martin
    Replies:
    3
    Views:
    135
  4. Jake Barnes
    Replies:
    2
    Views:
    111
  5. Replies:
    4
    Views:
    153
    Jonas Raoni
    Nov 21, 2006
Loading...

Share This Page