Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Determining object type

Avatar

Former Community Member
This is probably very simple but I'm stumped. I want to determine the type of object I'm manipulating using javascript. So if I have a function that takes an object as a parameter how can I tell if the object if a button, radiobutton, checkbox, etc.... I've tried
.className and several other things with no luck.



Here is a sample of what I am talking about



function doWhatever(fieldNode){

//determine type of object

if( fieldNode.className == "button"){

....

}

}

4 Replies

Avatar

Former Community Member
Hmm.
.className should work.

Most likely, 'fieldNode' is NULL.

Avatar

Former Community Member
Actually, I have the same dilemna myself, and .className only ever seems to return a value of "field" for any given 'field'. What I'd like to know is what
kind of field it is (e.g. date/time, decimal, numeric, textfield, etc.). Anyone know if this is possible?

Avatar

Level 7
What about the JavaScirpt 'typeof' special operator or the '.type' of field property? But since one can not tell the exact format of a text field since this can be dynamic, that is changed on the fly during another scripts processing. One could always examine the "formattedValue" and try to sort out the fields formatting.



The real solution is simply documentation or the use of PFN, Polish Field Notation.

Avatar

Former Community Member
Polish or Hungarian notation might work, but I'd probably have to redo all of the bindings on the xsd I'm using and possibly on the backend. I'm thinking I'll probably use Regular Expressions to assist me in the usage of the formattedValue to drill down to the most specific of field types.



I just ran across this link in another post though, so this will probably be my starting point:
http://www.adobe.com/support/products/enterprise/knowledgecenter/c4761.pdf