tags:

views:

22

answers:

1

I want to get diff Controls Id through java script??any control can be added by user on form java script will return the type of Control for ex textbox,label and its ID

+1  A: 

By controls, I'm assuming you mean form input controls. To get the id of an element, you can call .getAttribute('id') on an object. To get the type of a form element, access the 'type` attribute.

For example, if you want the id attribute and type of an input in the first form on a page, where the input has the name attribute "title":

var titleInput = document.forms[0].getElementsByName('title')[0];
alert("id = '" + titleInput.getAttribute('id') + "'\ntype = '" = titleInput.type + "'");
Tyson
Tyson this was great
You should mark my answer as "Accepted" :)
Tyson