473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

need script to expose more text

Hi,

Does anyone know where I can get a script that show a little plus sign after
a line of text, that when you click the plus sign, more text is revealed on
that same page, like a continuing paragraph. This will be on a web page.

Thanks!

--Randy Starkey
Jul 23 '05 #1
28 2549
Very rough, but you can modify it as you see fit...

<script type="text/javascript">
function expand(elem) {
elem.innerHTML = '-'
document.getElementById('more').style.display = 'block'
}
</script>

Start of text <a href="#" onclick="expand(this)">+</a>
<div id="more" style="display:none">More text</div>

"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> wrote in
message news:11*************@corp.supernews.com...
Hi,

Does anyone know where I can get a script that show a little plus sign
after a line of text, that when you click the plus sign, more text is
revealed on that same page, like a continuing paragraph. This will be on a
web page.

Thanks!

--Randy Starkey

Jul 23 '05 #2
Thanks! I'll play with it.

--Randy
"andrew" <no****@noname.com> wrote in message
news:cKgBe.107730$HI.46216@edtnps84...
Very rough, but you can modify it as you see fit...

<script type="text/javascript">
function expand(elem) {
elem.innerHTML = '-'
document.getElementById('more').style.display = 'block'
}
</script>

Start of text <a href="#" onclick="expand(this)">+</a>
<div id="more" style="display:none">More text</div>

"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> wrote in
message news:11*************@corp.supernews.com...
Hi,

Does anyone know where I can get a script that show a little plus sign
after a line of text, that when you click the plus sign, more text is
revealed on that same page, like a continuing paragraph. This will be on
a web page.

Thanks!

--Randy Starkey


Jul 23 '05 #3
ASM
Randy Starkey wrote:

Does anyone know where I can get a script that show a little plus sign after
a line of text, that when you click the plus sign, more text is revealed on
that same page, like a continuing paragraph. This will be on a web page.


<p onmouseover="t=this.childNodes[1].style; t.visibility='visible';"
onmouseout="t.visibility='hidden';">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<span style="visibility:hidden">Morbi a wisi. Mauris vulputate rutrum
arcu.</span>

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #4
ASM
Randy Starkey wrote:
Thanks! I'll play with it.


it was so beurk :-(

use of innerHTML
use of DIVs

<script type="text/javascript">
function expand(elem) {
var v = elem.firstChild.nodeValue;
elem.firstChild.nodeValue = v=='[+]'? '[-]':'[+]';
elem.parentNode.lastChild.style.visibility=v=='[+]'?'visible':'hidden';
}
</script>

<p>Start of text
<a href="#" onclick="expand(this); return false;">[+]</a><br>
<span style="visibility:hidden">More text</span>
</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<a href="#" onclick="expand(this); return false;">[+]</a>
<span style="visibility:hidden">Morbi a wisi. Mauris vulputate rutrum
arcu.</span>
</p>

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #5
I'm lost on the french - I don't know JS at all - are they comments?

--Randy
"ASM" <st*********************@wanadoo.fr> wrote in message
news:42**********************@news.wanadoo.fr...
Randy Starkey wrote:

Does anyone know where I can get a script that show a little plus sign
after a line of text, that when you click the plus sign, more text is
revealed on that same page, like a continuing paragraph. This will be on
a web page.


<p onmouseover="t=this.childNodes[1].style; t.visibility='visible';"
onmouseout="t.visibility='hidden';">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<span style="visibility:hidden">Morbi a wisi. Mauris vulputate rutrum
arcu.</span>

--
Stephane Moriaux et son [moins] vieux Mac

Jul 23 '05 #6
ASM <st*********************@wanadoo.fr> writes:
it was so beurk :-(
"beurk"?
use of innerHTML
Actually, innerHTML is supported in more browsers than DOM methods.
It's not the way to go for purity, and maybe not for future
compatability (although I doubt we'll ever see another HTML browser
that supports DOM and not innerHTML), but currently, it works.

It's overkill for this case, though, since there is no markup in the
"HTML" that is assigned.
use of DIVs
What's wrong with div's?
<script type="text/javascript">
function expand(elem) {
var v = elem.firstChild.nodeValue;
elem.firstChild.nodeValue = v=='[+]'? '[-]':'[+]';
elem.parentNode.lastChild.style.visibility=v=='[+]'?'visible':'hidden';
Have you tested this in, e.g., Mozilla? You are expecting the last
child node of the "p" element to be the "span" element. More likely,
it will be a text node containing the newline between "</span>" and
"</p>".
}
</script>

<p>Start of text
<a href="#" onclick="expand(this); return false;">[+]</a><br>
Why use a link, especially one with a non-sensical href like "#"
(something to be avioded generally). The link will make no sense
if javascript is disabled. For affordability to clicking, I would
prefer a button, not a link, since it doesn't link to anything.
(A good hint that one is misusing links is that they have no
meaningful; href :)

Using a link with an onclick also fails quite visibly if the script
errors, as the href is followed then (because you never reach the
"return false"). That is why it's better to use an object with no
inherent behavior, instead of trying to override it.

Using a link *does* make sense, if it links to a page with the
entire text visible. Then it would be a fall-back for javascript
disabled browsers.
<span style="visibility:hidden">More text</span>


You use "visibility" to hide the content. While it works in more
browsers than using "display" (e.g., Netscape 4 and Opera 6 and
other static DOM browsers), it also means that the hidden content
still takes up space in the flow of the page, which makes hiding
it pretty irrelevant.

So, my suggestion would be something like:
---
<script type="text/javascript">
function getElement(id) {
return document.getElementById ?
document.getElementById(id) :
document.all ?
document.all[id] :
null; // no need to fall back on Netscape here
}

function writeMoreButton(id) {
document.write("<input class='moreButton' type='button' value='+'",
" onclick='toggleMore(this,\"", id, "\");'>");
}

function toggleContent(id, visible) {
var elem = getElement(id);
(elem.style||elem).display = visible?"":"none";
}

function toggleMore(button,id) {
var expand = (button.value=="+");
toggleContent(id, expand);
button.value = expand ? "-" : "+";
}
</script>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
<span id="loremMore">Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</span>
<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>
</p>
---
You have to hide the element after it occurs in the file, but the
button can be placed anywhere you want.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
Lasse,

So this creates a small button? Also, I don't understand the language at the
end.

--Randy

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:ll**********@hotpop.com...
ASM <st*********************@wanadoo.fr> writes:
it was so beurk :-(


"beurk"?
use of innerHTML


Actually, innerHTML is supported in more browsers than DOM methods.
It's not the way to go for purity, and maybe not for future
compatability (although I doubt we'll ever see another HTML browser
that supports DOM and not innerHTML), but currently, it works.

It's overkill for this case, though, since there is no markup in the
"HTML" that is assigned.
use of DIVs


What's wrong with div's?
<script type="text/javascript">
function expand(elem) {
var v = elem.firstChild.nodeValue;
elem.firstChild.nodeValue = v=='[+]'? '[-]':'[+]';
elem.parentNode.lastChild.style.visibility=v=='[+]'?'visible':'hidden';


Have you tested this in, e.g., Mozilla? You are expecting the last
child node of the "p" element to be the "span" element. More likely,
it will be a text node containing the newline between "</span>" and
"</p>".
}
</script>

<p>Start of text
<a href="#" onclick="expand(this); return false;">[+]</a><br>


Why use a link, especially one with a non-sensical href like "#"
(something to be avioded generally). The link will make no sense
if javascript is disabled. For affordability to clicking, I would
prefer a button, not a link, since it doesn't link to anything.
(A good hint that one is misusing links is that they have no
meaningful; href :)

Using a link with an onclick also fails quite visibly if the script
errors, as the href is followed then (because you never reach the
"return false"). That is why it's better to use an object with no
inherent behavior, instead of trying to override it.

Using a link *does* make sense, if it links to a page with the
entire text visible. Then it would be a fall-back for javascript
disabled browsers.
<span style="visibility:hidden">More text</span>


You use "visibility" to hide the content. While it works in more
browsers than using "display" (e.g., Netscape 4 and Opera 6 and
other static DOM browsers), it also means that the hidden content
still takes up space in the flow of the page, which makes hiding
it pretty irrelevant.

So, my suggestion would be something like:
---
<script type="text/javascript">
function getElement(id) {
return document.getElementById ?
document.getElementById(id) :
document.all ?
document.all[id] :
null; // no need to fall back on Netscape here
}

function writeMoreButton(id) {
document.write("<input class='moreButton' type='button' value='+'",
" onclick='toggleMore(this,\"", id, "\");'>");
}

function toggleContent(id, visible) {
var elem = getElement(id);
(elem.style||elem).display = visible?"":"none";
}

function toggleMore(button,id) {
var expand = (button.value=="+");
toggleContent(id, expand);
button.value = expand ? "-" : "+";
}
</script>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
<span id="loremMore">Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</span>
<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>
</p>
---
You have to hide the element after it occurs in the file, but the
button can be placed anywhere you want.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #8
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:

Please don't top post.
So this creates a small button?
Yes, just a button with a "+" or "-" in it. If you want it styled,
just use CSS and style the class "moreButton".
Also, I don't understand the language at the end.


Lorem ipsum? Just the generic garble text. Read about it here:
<URL:http://www.lipsum.com/>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
ASM
Lasse Reichstein Nielsen wrote:
ASM <st*********************@wanadoo.fr> writes:
it was so beurk :-(
"beurk"?


BeuArk, Pfffft, Pzll, Prout, Sprrllt,
as you like to say :-p or [not too good] or [not elegant]
use of innerHTML


Actually, innerHTML is supported in more browsers than DOM methods.
It's not the way to go for purity, and maybe not for future
compatability (although I doubt we'll ever see another HTML browser
that supports DOM and not innerHTML), but currently, it works.


All as text-align in css
(this M$ malfunction pushing other navigators to support it)
What's wrong with div's?
I'd read you must try to use other tags most of time,
and, if really not possible to do other way,
well ... at least ... by the end ... ok a div.
<script type="text/javascript">
function expand(elem) {
var v = elem.firstChild.nodeValue;
elem.firstChild.nodeValue = v=='[+]'? '[-]':'[+]';
elem.parentNode.lastChild.style.visibility=v=='[+]'?'visible':'hidden';

Have you tested this in, e.g., Mozilla?


I did in FF, IE, Opera, Safari and Camino (on Mac 10.3.9)
When I give some code on a ng, usually I tested it.
If not, I say it. (not tested)
in JS a coma or quote is so easily forgotten ...
You are expecting
I expect nothing
You have to do :
put the hidden-to-visible part of text in a span in end of p
if you expect to use this function :-)
the last
child node of the "p" element to be the "span" element. More likely,
it will be a text node containing the newline between "</span>" and
"</p>".
of course, if way of doing is not respected ... where do we go?
(tell me how you hide by css an element which is not one </span>foo</p>)
}
</script>

<p>Start of text
<a href="#" onclick="expand(this); return false;">[+]</a><br>

Why use a link, especially one with a non-sensical href like "#"


I did adapt a proposed code without giving an other one too much far
from original.
original script had this link to receive the onclick
... didn't go further.

Overall I did give an other approach to reveal the hidden text.
(something to be avioded generally). The link will make no sense
if javascript is disabled. For affordability to clicking, I would
prefer a button, not a link, since it doesn't link to anything.
(A good hint that one is misusing links is that they have no
meaningful; href :)
I do not understand in what a button would work better if JS is disabled
And as I used to code for NC4.5, in this case the button has to be in a
form.

Anyway, there are so much ways to propose a click :
A, img, button ... and even P, td, div, and so on
Using a link with an onclick also fails quite visibly if the script
errors, as the href is followed then (because you never reach the
"return false"). That is why it's better to use an object with no
inherent behavior, instead of trying to override it.
OK, you're right
<span style="visibility:hidden">More text</span>

You use "visibility" to hide the content. While it works in more
browsers than using "display" (e.g., Netscape 4 and Opera 6 and
other static DOM browsers), it also means that the hidden content
still takes up space in the flow of the page,


Where is my dictionary? Ha ! irrelevant : out of purpose, out of words
which makes hiding it pretty irrelevant.
Sure ! but I don't know what the guy wants exactly to do
(few words? complete page of 258 lines ? it's his problem).
I just give a soluce.
And, remenber, here was only an exercice to avoid innerHTML
(in an existing script)

Never I use display on/off (with a relative)
because that gives a very bad yoyo effect to the draw of page
So, my suggestion would be something like:
---
<script type="text/javascript">
function getElement(id) {
return document.getElementById ?
document.getElementById(id) :
document.all ?
document.all[id] :
null; // no need to fall back on Netscape here
}
Yeap, good introduction :-)
function writeMoreButton(id) {
document.write("<input class='moreButton' type='button' value='+'",
" onclick='toggleMore(this,\"", id, "\");'>");
}
Ho! it's what you mean by JS disabled ?
so you can do it with no matter what (whom a A)
function toggleContent(id, visible) {
var elem = getElement(id);
(elem.style||elem).display = visible?"":"none";
}
function toggleMore(button,id) {
var expand = (button.value=="+");
toggleContent(id, expand);
button.value = expand ? "-" : "+";
}
</script>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
<span id="loremMore">Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</span>
I love your french(*) ;-)
<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>
</p>
---
You have to hide the element after it occurs in the file, but the
button can be placed anywhere you want.


The A in code given in my post had the advantage to show [+] or [-]
depend last action launched by the click

If IE would be more clever a css rule would be enough ... :-(
(*) personal jock relative to a certain post back
not matter if not understood (it's not for you)
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #10
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:d5**********@hotpop.com...
Please don't top post.
OK. I'm not sure I know what this means, but I assume it means posting
before quoting? If so, OK.
Lorem ipsum? Just the generic garble text. Read about it here:
<URL:http://www.lipsum.com/>


OK - follow that.

Question - will this script simply put the button at the end of a line of
text, and then continue text when the plus is clicked? I need the default to
be collapsed with the plus showing, and the plus sign (or button) to go
simply at the end of a line of text. Also, do I need anything on the page at
the top after the body tag, or just copy in the script where I need it?
Thanks!

--Randy
Jul 23 '05 #11
ASM
Randy Starkey wrote:
I'm lost on the french -


Which french ?

I don't know JS at all - are they comments?

Put this complete example in an html page and try it
That works pulling mouse over visible part of text.
A kind of roll-over

The hidden to visible part of text must be set between span tags
at the last of P element

I leave the example for your use

<p onmouseover="t=this.childNodes[1].style; t.visibility='visible';"
onmouseout="t.visibility='hidden';"
style="color:blue">
Here is a sentence whom unique goal is to reveal an other text. Pass
your mouse over me.
<span style="visibility:hidden;color:red"> I am the complementary part
of text.</span>
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #12
ASM
Randy Starkey wrote:

Question - will this script simply put the button at the end of a line of
text, and then continue text when the plus is clicked? I need the default to
be collapsed with the plus showing, and the plus sign (or button) to go
simply at the end of a line of text. Also, do I need anything on the page at
the top after the body tag, or just copy in the script where I need it?
Thanks!


copy/past all what proposed marked by '---' (from <script to </p>)
between tags <html> and </html>
in your notepad or other text editor
save as foo.htm

open this foo.htm in your browser and see and try the button

explain :
put the 1st script in header (between head tags)

where you want a button you past this code :

<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>

then just after (or before if prefered) this script
you put your hidden text inside a span *idded* :

<span id="here_01">
My hidden text here
</span>

Do not forget to change the name in the script according to this of span
-> change "lorenMore" with "here_01"

that could give us :

<p>then just after this script you put your hidden text
inside a span or a P or a div *idded* : <script type="text/javascript">
writeMoreButton("here_01"); toggleContent("here_01", false);</script>
<br><span id="here_01"> My hidden text here</span>
</p>
<p>Other test : <script type="text/javascript">
writeMoreButton("here_02"); toggleContent("here_02", false);</script>
<span id="here_02"> second secret text</span>
</p>

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #13
"ASM" <st*********************@wanadoo.fr> wrote in message
news:42*********************@news.wanadoo.fr...
Randy Starkey wrote:
I'm lost on the french -
Which french ?

I don't know JS at all - are they comments?

Put this complete example in an html page and try it
That works pulling mouse over visible part of text.
A kind of roll-over


OK - Thanks!


The hidden to visible part of text must be set between span tags
at the last of P element

I leave the example for your use

<p onmouseover="t=this.childNodes[1].style; t.visibility='visible';"
onmouseout="t.visibility='hidden';"
style="color:blue">
Here is a sentence whom unique goal is to reveal an other text. Pass your
mouse over me.
<span style="visibility:hidden;color:red"> I am the complementary part of
text.</span>
--
Stephane Moriaux et son [moins] vieux Mac

Jul 23 '05 #14
"ASM" <st*********************@wanadoo.fr> wrote in message
news:42**********************@news.wanadoo.fr...
copy/past all what proposed marked by '---' (from <script to </p>)
between tags <html> and </html>
in your notepad or other text editor
save as foo.htm
OK. I think I got it. Thanks!


open this foo.htm in your browser and see and try the button

explain :
put the 1st script in header (between head tags)

where you want a button you past this code :

<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>

then just after (or before if prefered) this script
you put your hidden text inside a span *idded* :

<span id="here_01">
My hidden text here
</span>

Do not forget to change the name in the script according to this of span
-> change "lorenMore" with "here_01"

that could give us :

<p>then just after this script you put your hidden text
inside a span or a P or a div *idded* : <script type="text/javascript">
writeMoreButton("here_01"); toggleContent("here_01", false);</script>
<br><span id="here_01"> My hidden text here</span>
</p>
<p>Other test : <script type="text/javascript">
writeMoreButton("here_02"); toggleContent("here_02", false);</script>
<span id="here_02"> second secret text</span>
</p>

--
Stephane Moriaux et son [moins] vieux Mac

Jul 23 '05 #15
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:d5**********@hotpop.com...
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:

So this creates a small button?


Yes, just a button with a "+" or "-" in it. If you want it styled,
just use CSS and style the class "moreButton".


I'm getting double buttons for some reason?
See http://www.victorychurch.com/?page=52
slight adjustment needed?
Thanks! - Randy


Jul 23 '05 #16
"andrew" <no****@noname.com> wrote in message
news:cKgBe.107730$HI.46216@edtnps84...
Very rough, but you can modify it as you see fit...

<script type="text/javascript">
function expand(elem) {
elem.innerHTML = '-'
document.getElementById('more').style.display = 'block'
}
</script>

Start of text <a href="#" onclick="expand(this)">+</a>
<div id="more" style="display:none">More text</div>


simple and works to expand, but won't collapse?
--Randy

Jul 23 '05 #17
ASM
Randy Starkey wrote:
I'm getting double buttons for some reason?
See http://www.victorychurch.com/?page=52


you did write it twice
ist with javascript
2d with html

delete the 2nd

<SCRIPT type=text/javascript>
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</SCRIPT>

here : line to delete
<INPUT class=moreButton onclick='toggleMore(this,"loremMore");'
type=button value=+>

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #18
ASM
Randy Starkey wrote:
"andrew" <no****@noname.com> wrote in message
news:cKgBe.107730$HI.46216@edtnps84...
simple and works to expand, but won't collapse?


these I did give do
<script type="text/javascript">
function showHide(elem) {
var v = elem.firstChild.nodeValue;
elem.firstChild.nodeValue = v=='[+]'? '[-]':'[+]';
elem.parentNode.lastChild.style.visibility=v=='[+]'?'visible':'hidden';
}
</script>

<p>Start of text
<a href="#" onclick="showHide(this); return false;">[+]</a><br>
<span style="visibility:hidden">More text</span>
</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<a href="#" onclick="showHide(this); return false;">[+]</a>
<span style="visibility:hidden">Morbi a wisi. Mauris vulputate rutrum
arcu.</span>
</p>

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #19
ASM <st*********************@wanadoo.fr> writes:
where you want a button you past this code :

<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>

then just after (or before if prefered) this script
you put your hidden text inside a span *idded* :
Actually, you should put the call to "writeMoreButton" where you want
the button, but the call to "toggleContent" *after* the content that
must be hidden.

that could give us :

<p>then just after this script you put your hidden text
inside a span or a P or a div *idded* : <script type="text/javascript">
writeMoreButton("here_01"); toggleContent("here_01", false);</script> just:
writeMoreButton("here_01");</script>
<br><span id="here_01"> My hidden text here</span>

and
<script type="text/javascript">toggleContent("here_01",false);</script>
here.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #20
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:8y**********@hotpop.com...
ASM <st*********************@wanadoo.fr> writes: Actually, you should put the call to "writeMoreButton" where you want
the button, but the call to "toggleContent" *after* the content that
must be hidden.
OK - I'm just learning this. Thanks!



that could give us :

<p>then just after this script you put your hidden text
inside a span or a P or a div *idded* : <script type="text/javascript">
writeMoreButton("here_01"); toggleContent("here_01", false);</script>

just:
writeMoreButton("here_01");</script>
<br><span id="here_01"> My hidden text here</span>

and
<script type="text/javascript">toggleContent("here_01",false);</script>
here.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #21
"ASM" <st*********************@wanadoo.fr> wrote in message
news:42***********************@news.wanadoo.fr...
Randy Starkey wrote:
I'm getting double buttons for some reason?
See http://www.victorychurch.com/?page=52
you did write it twice
ist with javascript
2d with html

delete the 2nd


Hmmm... OK. I'm just learning this. Thanks! Also for the other message and
script.
--Randy

<SCRIPT type=text/javascript>
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</SCRIPT>

here : line to delete
<INPUT class=moreButton onclick='toggleMore(this,"loremMore");'
type=button value=+>

--
Stephane Moriaux et son [moins] vieux Mac

Jul 23 '05 #22
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:ll**********@hotpop.com...
ASM <st*********************@wanadoo.fr> writes:
it was so beurk :-(
"beurk"?
use of innerHTML


Actually, innerHTML is supported in more browsers than DOM methods.
It's not the way to go for purity, and maybe not for future
compatability (although I doubt we'll ever see another HTML browser
that supports DOM and not innerHTML), but currently, it works.

It's overkill for this case, though, since there is no markup in the
"HTML" that is assigned.
use of DIVs


What's wrong with div's?
<script type="text/javascript">
function expand(elem) {
var v = elem.firstChild.nodeValue;
elem.firstChild.nodeValue = v=='[+]'? '[-]':'[+]';
elem.parentNode.lastChild.style.visibility=v=='[+]'?'visible':'hidden';


Have you tested this in, e.g., Mozilla? You are expecting the last
child node of the "p" element to be the "span" element. More likely,
it will be a text node containing the newline between "</span>" and
"</p>".
}
</script>

<p>Start of text
<a href="#" onclick="expand(this); return false;">[+]</a><br>


Why use a link, especially one with a non-sensical href like "#"
(something to be avioded generally). The link will make no sense
if javascript is disabled. For affordability to clicking, I would
prefer a button, not a link, since it doesn't link to anything.
(A good hint that one is misusing links is that they have no
meaningful; href :)

Using a link with an onclick also fails quite visibly if the script
errors, as the href is followed then (because you never reach the
"return false"). That is why it's better to use an object with no
inherent behavior, instead of trying to override it.

Using a link *does* make sense, if it links to a page with the
entire text visible. Then it would be a fall-back for javascript
disabled browsers.
<span style="visibility:hidden">More text</span>


You use "visibility" to hide the content. While it works in more
browsers than using "display" (e.g., Netscape 4 and Opera 6 and
other static DOM browsers), it also means that the hidden content
still takes up space in the flow of the page, which makes hiding
it pretty irrelevant.

So, my suggestion would be something like:
---
<script type="text/javascript">
function getElement(id) {
return document.getElementById ?
document.getElementById(id) :
document.all ?
document.all[id] :
null; // no need to fall back on Netscape here
}

function writeMoreButton(id) {
document.write("<input class='moreButton' type='button' value='+'",
" onclick='toggleMore(this,\"", id, "\");'>");
}

function toggleContent(id, visible) {
var elem = getElement(id);
(elem.style||elem).display = visible?"":"none";
}

function toggleMore(button,id) {
var expand = (button.value=="+");
toggleContent(id, expand);
button.value = expand ? "-" : "+";
}
</script>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
<span id="loremMore">Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</span>
<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>
</p>
---


You have to hide the element after it occurs in the file, but the
button can be placed anywhere you want.

I don't understand what you mean by this.
Also - is there a way of shortening the height of the button slightly? It's
throwing my line spacing off some. Thanks! --Randy

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #23
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> wrote in
message news:11*************@corp.supernews.com...
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:d5**********@hotpop.com...
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:
So this creates a small button?


Yes, just a button with a "+" or "-" in it. If you want it styled,
just use CSS and style the class "moreButton".


could you give me a CSS code line that would make the button not quite so
tall? Just a bit shorter.
Thanks! --Randy


I'm getting double buttons for some reason?
See http://www.victorychurch.com/?page=52
slight adjustment needed?
Thanks! - Randy

Jul 23 '05 #24
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> wrote in
message news:11*************@corp.supernews.com...

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
Yes, just a button with a "+" or "-" in it. If you want it styled,
just use CSS and style the class "moreButton".


could you give me a CSS code line that would make the button not quite so
tall? Just a bit shorter.


Try:
---
<style type="text/css">
.moreButton { height: 1em; width: 1em; }
</style>
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #25
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:hd**********@hotpop.com...
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> wrote in
message news:11*************@corp.supernews.com...
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message Yes, just a button with a "+" or "-" in it. If you want it styled,
just use CSS and style the class "moreButton".


could you give me a CSS code line that would make the button not quite so
tall? Just a bit shorter.


Try:
---
<style type="text/css">
.moreButton { height: 1em; width: 1em; }
</style>


OK. Thanks!
--Randy

---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #26

"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:hd**********@hotpop.com...
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> wrote in
message news:11*************@corp.supernews.com...
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message Yes, just a button with a "+" or "-" in it. If you want it styled,
just use CSS and style the class "moreButton".


could you give me a CSS code line that would make the button not quite so
tall? Just a bit shorter.


Try:
---
<style type="text/css">
.moreButton { height: 1em; width: 1em; }
</style>


Here's the full script with style inserted - seems to kill the script
working. I'm doing something wrong.
--Randy

<HTML>
<script type="text/javascript">
function getElement(id) {
return document.getElementById ?
document.getElementById(id) :
document.all ?
document.all[id] :
null; // no need to fall back on Netscape here
}

function writeMoreButton(id) {
document.write("<input class='moreButton' type='button' value='+'",
" onclick='toggleMore(this,\"", id, "\");'>");
}

<style type="text/css">
.moreButton { height: 1em; width: 1em; }
</style>

function toggleContent(id, visible) {
var elem = getElement(id);
(elem.style||elem).display = visible?"":"none";
}

function toggleMore(button,id) {
var expand = (button.value=="+");
toggleContent(id, expand);
button.value = expand ? "-" : "+";
}
</script>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
<span id="loremMore">Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</span>
<script type="text/javascript">
writeMoreButton("loremMore");
toggleContent("loremMore", false);
</script>
</p>
</HTML>
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'

Jul 23 '05 #27
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes:
Here's the full script with style inserted - seems to kill the script
working. I'm doing something wrong.


You are putting the style element inside the script element.
Put them next to each other in the head element of the page.

Before trying to do advanced stuff like expanding text, maybe
you should learn basic HTML and CSS. That would make you able
to fix small things like this yourself.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #28
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:d5**********@hotpop.com...
"Randy Starkey" <ra*****************@NOSPAMvictorychurch.com> writes: You are putting the style element inside the script element.
Put them next to each other in the head element of the page.

Before trying to do advanced stuff like expanding text, maybe
you should learn basic HTML and CSS. That would make you able
to fix small things like this yourself.


Right. Thanks. I actually figured it out a little bit ago.
It's here... www.victorychurch.com/?page=53
I probably need to just job it out. Although I'm an engineer, I don't have
time to learn a new skill right now. I thought it might be a small script,
and you can see from my page I'm going to use it about 20 times on the same
page. As usual, it turns out there is a bit more to it when one goes to fit
it in exactly right. I'm not using the style, as the character gets off
center on the button when I resize it. It's close enough now though. Thanks
for the code. I appreciate it, and it's basically solved now I
hink. --Randy
Jul 23 '05 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Radioactive Man | last post by:
I am fairly new to the latest verion of Python and using it on windows 95, 2000, and/or XP. What libraries, modules, functions, etc. would I need to set up a Python script to download a file, say...
2
by: tmb | last post by:
- Want to open a 2nd browser window when someone clinks a link with the link content inside it. - Want to control window size - Want all tool bars so only blue bar at top shows - Can I put my...
6
by: lucy | last post by:
Hello comp.lang.js.I need a script to rotate a background image on each newpage load, given the id of the element and a list (array?)of 2 or more image paths ("img1.jpg", "img2.jpg", ...).Actually,...
2
by: eric dexter | last post by:
I need to take text from one file and then save it to a different file. I also need to return any comment The def should have variables for the file that should be read in, the file it should...
5
by: atcohaz | last post by:
I need script in php for web mail log in to add in my any web page www.hazratsultanbahu.com/webmail www.hazratsultanbahu.com/webmail Can you help me in php Yours truly, M Farooq...
2
by: S Moran | last post by:
many moons ago i had a small app that you could drag onto a textbox in an application or on a website that contained text that was hidden with asterisks and the underlying text would be revealed....
1
by: eis | last post by:
Please I need help. I need script , so people can add items on my website as shop.com or overstock.com , where I can look? or who can do it for me?
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I need to toggle the text on an html input button in a .net web application. the name of the button is btn_hide and I do have an onclick function for it. <script language="javascript"...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.