The goal is to look if the modified Prototype actually works. Let's make an object hide and show on user action.
hide
this is a test object which should hide and show on user action
I created an action link and object on which action will be taken. I gave them ids test_hide and test_hide_button
Prototype accesses the DOM elements using $( function. Because it is a modification, I have to use id_name
)$ID(.id_name
)
Example uses hide() and show() Prototype functions.
<a id='test_hide_button' onclick="showhide('test_hide')">hide</a>
<p id='test_hide'>this is a test object which should hide and show on user action</p>
<script type='text/javascript'>
function showhide( id ) {
if ($ID(id).hidden) {
$ID(id).show();
$ID(id).hidden = false;
$ID(id + '_button').innerHTML = 'hide';
} else {
$ID(id).hide();
$ID(id).hidden = true;
$ID(id + '_button').innerHTML = 'show';
}
}
</script>
Trackback URL for this post:
http://piotr.zalewa.info/trackback/8









Comments
dear friend,and i think it is very good information.thank you very much.
Thanks for a good script. It really works.
So what is best? Follow this script or totally replace drupal's jQuery with Prototype as you people say?? Can i have some help ??
Its a good script but i am really thinking of fully replace drupal's jQuery into Prototype. Thanks.
The modification you have detailed here is really a simple one. You this helps server and hosting packager for you site and other related server too. I am searching similar coding to make user comfort too. It will be more effective if different hosting package are served from same data base as per Google do.
Thanks for sharing this information.
Its a good script and congrats to you that you have figured it out.
But I am really thinking of fully replace drupal's jQuery into Prototype. Haven't found anything like this for the moment.
Thanks what about time delay?
Will do, But I am really thinking of fully replace drupal's jQuery into Prototype. Haven't found anything like this for the moment.
Thanks for this! I used it with some modifications and it worked well!
Keep posting more of such code!
Thanks! Prem