Forum: Ruby on Rails Javascript

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3083ca8f0496edaac2fa10c20630d0bc?d=identicon&s=25 Newb Newb (newb)
on 2008-11-11 09:59
Hi.
In my App i have Tabs like below

[Manage Contacts] [Roles] [users] [Contact Us]

<a href="#" id="d1" onclick= "tp_select();">Manage Accounts</a>
<a href="#" id="d2" onclick= "tp_select();">Roles</a>
<a href="#" id="d3">onclick= "tp_select();">Users</a>
<a href="#" id="d4">onclick= "tp_select();">Contact Us</a>

[On click Event]if user clicks on  Roles tab means the Style class
"tp_select" has to be called for Roles tab.
and if user clicks on Contact Us tab means the Style class "tp_select"
has to be called for Contact Us tab.
#-----i ve done java script function----#
function tp_select() {
    $('d1').addClassName('tp_select')


}

#--------------#
i don't know how to call this function for all the element.
it works for Manage Accounts tab.
i don't know how to write javascript function for all the tab.
Pls help me on this.
Pls advice.
D69d23d8e811e8ab2a8593380d6ede63?d=identicon&s=25 Jeff Emminger (jemminger)
on 2008-11-11 20:08
(Received via mailing list)
maybe like so?


<a href="#" id="d1" class='tab_link' onclick=
"tp_select(this);">Manage Accounts</a>
<a href="#" id="d2" class='tab_link' onclick=
"tp_select(this);">Roles</a>
<a href="#" id="d3" class='tab_link' onclick=
"tp_select(this);">Users</a>
<a href="#" id="d4" class='tab_link' onclick=
"tp_select(this);">Contact Us</a>

function tp_select(a) {
  // clear out the others
  $$('.tab_link').each(function(el){
    el.removeClassName('tp_select')
  })
  // add back in for this one
  $(a.id).addClassName('tp_select')
}



On Nov 11, 3:59 am, Newb Newb <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.