Forum: Ruby on Rails Executing multiple JavaScript commands?

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.
mbonig (Guest)
on 2005-12-01 05:34
(Received via mailing list)
I'm reading in, the only RoR book I could find in the local bookstore,
_Agile Web D. with Rails_. In the Web 2.0 section they talk
about
using DOM manipulating JavaScript commands like "Element.Toggle(element,
...)". I like how those work, but want to execute multiple commands on
one
event.

I want to be able to do a:
$('some_id').style.display='none'
then a
$('another_id').style.display='inline'

both on a "onclick" event:
<div id="shade" onclick="$('shade').style.display='none'">

any help would be appreciated.
Thanks,
mvette13 (Guest)
on 2005-12-01 05:43
(Received via mailing list)
Couple ways you could do it...

#1
Make a javascript function....
function clickme(id1, id2) {
     $('id2').style.display='none';
     $('id3').style.display='inline'; }
then call the function in the onclick attribute...
<div id="shade" onclick="clickme('shade', 'something_else');">

#2
you can put 2 lines on the onclick attribute (semi-colon separated
lines)
<div id="shade"
onclick="$('shade').style.display='none';$('something_else').style.display='inline';">

Hope that helps,
Mark
This topic is locked and can not be replied to.