• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Controlling element ids inside a table

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Below is a section of my jsp code


Now i am able to execute the hyperlink on the first row, but not on the others. understandably the id is same for all the hyperlinks. how do i assign dynamic ids to the hyperlinks & tables such that i am able to toggle individual tables per hyperlinks
 
author
Posts: 15385
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um, use the i variable in your loop? Or better yet, use a jQuery selector that finds the next table!

Eric
 
sumit anand kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:Um, use the i variable in your loop? Or better yet, use a jQuery selector that finds the next table!

Eric


Yeah Eric, I too thought so, but how do i change==> id="link1" to "link[i]" for each href and how do i tell jquery that every click of "link[i]" toggles "table[i]"
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
id values are overused, in my opinion, and they are not even necessary here.

My advice is to ditch the ids.

Use a jQuery selector to apply the click handler to all the links in the tables with one statement, and use .closest() to find the parent table for toggling.

I also advise to stop using obsolete Java scriptlets in your JSPs. It's time to step out of 2002 and into 2012.
 
sumit anand kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:
I also advise to stop using obsolete Java scriptlets in your JSPs. It's time to step out of 2002 and into 2012.


Thanks Bear. I must say i am a bit rusty because its now quite a while i used javascripts. Also i am very exited to use jQuery and the hell lot of cool features it provides, not to mention it being easy.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic