Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-31-2008, 03:40 PM   PM User | #1
blast
New Coder

 
Join Date: Jan 2008
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
blast is an unknown quantity at this point
toggle() more or less [text]

Hello All,

I am trying to find some help on using prototype/scriptaculous toggle()

Code:
<div>
Initial Text of the paragraph
<div style="display: none;" id="jan1">
    whatever more text i want to show.
</div>

<a href="javascript:void(0);" onClick="showHide('do_more_less','jan1'); return false;"><span id="do_more_less">More</span></a>

</div>
here is the JS

Code:
function showHide(id, iShow)
{
	var id = id;
	var iShow = iShow;
        var moreLess = document.getElementById(id).innerHTML;
        moreLess = (moreLess == "More") ? "More" : "Less";
	Element.toggle(iShow);
}

now what im trying to do is....have the opening text (which if there is an easier way, please let me know)...when you click on 'more' it will toggle the ID to display it (simple enough), BUT....i want the word 'more' to change to 'less'

any help would be appreciated.
blast is offline   Reply With Quote
Old 02-01-2008, 05:19 AM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
If you write this line
Code:
moreLess = (moreLess == "More") ? "More" : "Less";
to be if statements it would look like:
var moreLess;
Code:
if(moreLess == "More"){
  moreLess = "More";
}
else{
  moreLess = "Less";
}
Do you see the problem?
Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:09 PM.


Advertisement
Log in to turn off these ads.