• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Object id not getting

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<td>
<a id="FacilityList_1_0" href="javascript:LaunchFacilityDetail(this)">DETAIL</a>
</td>

my js function:
function LaunchFacilityDetail(obj) {
alert(obj);
}

alert(obj) is giving me the result: [object Window]
alert(obj.id) is giving me the result: undefined

Why I am not getting object id and what is that '[object Window]' ???
Please let me know about it.
 
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the window object. What did you want it to be?
 
Bear Bibeault
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Using the "javascript:" pseudo-protocol on a link is a really iffy and archaic way of triggering a JavaScript function. Why aren't you using a more straight-forward onclick handler?

In fact, if you don't want it to be a real link, why us an <a> tag in the first place?
 
Ja vardhan
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

this is my requirement:



My table is constructed using the PHP code, all the table data is retrieved from database, I run the query from PHP code and construct the table.

In table all first column elements are like links, when I click on first column(table heading 'Click for Detail') of the row... I need to get the value of the same row's third column (table heading 'Facility Name') and I need to display all details of that 'facility'(I will run query to get all these details) under another TAB in the same page.

When I click on first column, to get the same row'w third column value... I did not get any approach. So I gave 'id' to all 'td' elements when constructing table in php. Now if I can get the 'id' of the 'td' element clicked, then I can get coresponding third column value and proceed further.

Hope I gave the clear explanation.

please tell me how can I get the id of clicked 'td' element?
 
Bear Bibeault
Marshal
Posts: 67463
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, use an onclick handler rather than the "javascript:" pseduo-protocol. Why complicate something that can be really simple?

The element doesn't need to be an <a> tag even, it can be a <span>, or if it's really the id of the <td> that you want, just put the handler on the <td> itself.

In the handler, the clicked item is available as part of the Event instance.
[ October 11, 2008: Message edited by: Bear Bibeault ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic