Two Laptop Bag*
The moose likes HTML, CSS and JavaScript and the fly likes how to get the object name when i pass parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to get the object name when i pass parameter " this" ?" Watch "how to get the object name when i pass parameter " this" ?" New topic
Author

how to get the object name when i pass parameter " this" ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi, is it possible that when we pass a "this" as function parameter, then we can get back the object name ?

for instance,

if we have checkbox field as below


and when user click select or unselect checkbox, and the selectCheckBox(this) function will call .. but then can we get the name of checkbox which is in this case as "chkbox1" ?

thank you for answering
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
As I said before the posts got deleted due to the server problem,

You would just do

function selectCheckBox(xElem){
alert(xElem.name);
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to get the object name when i pass parameter " this" ?
 
Similar Threads
Radio button
insertCell() method's returned object properties
Getting the TD value using JavaScript + TD does not contain any ID.
MultiDimenaional Array sort
Dynamic form/checkbox problem