Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with disabling div

27 views
Skip to first unread message

jivan...@poczta.onet.pl

unread,
Aug 20, 2016, 3:32:22 AM8/20/16
to
In PHP code I have:

if ($images + $movies > 0) {
echo "<tr><td>Attachements:</td><td>";
echo '</td></tr>';
echo '<tr><td></td><td><div id="attachments">';
$dir = getPicturesDir($fullAnnouncementNo);
$picturesDir = substr($dir, strlen(FCPATH) + 1);
$pictures = getPicturesOf($fullAnnouncementNo);
foreach ($pictures as $p) {
if (isMovie($p)) {
echo '<object data="' . base_url($picturesDir . '/' . $p) . '"></object>';
} elseif (isImage($p)) {
echo '<img src="' . base_url($picturesDir . '/' . $p) .'">';
}
}
}

I want to disable attachments div when printing.

function setCurrentStyle(elem, cssProperty, cssValue) {
if (elem.currentStyle) { // IE
elem.currentStyle[cssProperty] = cssValue;
elem.style[cssProperty] = cssValue;
} else if (window.getComputedStyle) {
elem.style[cssProperty] = cssValue;
}
}

function printAnnouncement() {
var btn1 = document.getElementById('print_announcement');
var btn2 = document.getElementById('summary');
var att = document.getElementById('attachments');
var i;
setCurrentStyle(btn1, 'display', 'none');
setCurrentStyle(btn2, 'display', 'none');
setCurrentStyle(att, 'display', 'none');
window.print();
setCurrentStyle(btn1, 'display', '');
setCurrentStyle(btn2, 'display', '');
setCurrentStyle(att, 'display', 'block');
}

Buttons print_announcement and summary are correctly disabled when printAnnouncement() is called. Div attachment is still visible. I don't understand why.
Please help.

Osmo Saarikumpu

unread,
Aug 20, 2016, 3:55:51 AM8/20/16
to
On 20/08/2016 10:32, jivan...@poczta.onet.pl wrote:
> I want to disable attachments div when printing.

I'm probably missing something here, but I'd try:

<style type="text/css" media="print">
#attachments {display:none;}
</style>

Or, instead of the display property. use:

visibility:hidden;

if layout preservation is needed.

--
Best wishes, Osmo

jivan...@poczta.onet.pl

unread,
Aug 20, 2016, 5:08:24 AM8/20/16
to
W dniu sobota, 20 sierpnia 2016 09:55:51 UTC+2 użytkownik Osmo Saarikumpu napisał:
> <style type="text/css" media="print">
> #attachments {display:none;}
> </style>

You are great, your solution is perfect. Thanks a lot!

Jivanmukta

unread,
Aug 24, 2016, 3:23:44 AM8/24/16
to
I added to my view "show/hide attachments" button. I want to have
attachments invisible by default. When user presses "show attachments" the
attachments (images and movies) should be shown. When user presses "hide
attachments" the attachments should be hidden. The attachments should never
be printed.

Here is main part of my view:

<div align="center">
<input id="print_announcement1" name="print_announcement" type="button"
class="normal_button" value="Print announcement" onclick="window.print();">
</div>
<br>
<style type="text/css" media="print">
input#print_announcement1, input#summary1, input#print_announcement2,
input#summary2, input#show_hide_attachments, div#attachments { display:
none; }
</style>
<script type="text/javascript">
function showHideAttachments(btn) {
var a = document.getElementById('attachments');
var movies = document.getElementsByTagName('embed');
var i;
if (a.style.visibility == 'hidden') {
a.style.visibility = 'visible';
for (i = 0; i < movies.length; i++) {
movies[i].hidden = false;
}
btn.value = 'Hide attachments';
} else if (a.style.visibility == 'visible') {
a.style.visibility = 'hidden';
for (i = 0; i < movies.length; i++) {
movies[i].hidden = true;
}
btn.value = 'Show attachments';
}
}
</script>
<table id="printout" border="0">
<caption>
<h6>Announcement</h6>
<hr>
</caption>
<tfoot>
<tr><td colspan="2"><hr></td></tr>
</tfoot>
<tbody>
... <!-- announcement data -->
<?php
if ($images + $movies > 0) {
echo "<tr><td>Attachments:</td><td>";
echo '<b>', $images, ' images, ', $movies, ' movies</b> ';
echo '<input id="show_hide_attachments" type="button" value="Show
attachments" onclick="showHideAttachments(this);">';
echo '</td></tr></tbody></table>';
echo '<div id="attachments" align="center" style="visibility: hidden">';
$dir = getPicturesDir($fullAnnouncementNo);
$picturesDir = substr($dir, strlen($publicHtmlDir) + 1);
$pictures = getPicturesOf($fullAnnouncementNo);
foreach ($pictures as $p) {
if (isMovie($p)) {
echo '<embed hidden="true" autostart="false" height="0"
width="0" src="' . base_url($picturesDir . '/' . $p) . '"><br>';
} elseif (isImage($p)) {
echo '<img src="' . base_url($picturesDir . '/' . $p) .'"><br>';
}
}
echo '<input id="print_announcement2" name="print_announcement"
type="button" class="normal_button" value="Print announcement"
onclick="window.print();">';
echo '</div>';
}
?>

I use <embed hidden="true" autostart="false" ...> becase I don't want the
movies to be displayed at document load.
The problem is that the movies are not displayed at all when user presses
"show attachments". I don't know why and I don't know how to program it
correctly.
Please help.

Evertjan.

unread,
Aug 24, 2016, 4:30:35 AM8/24/16
to
Jivanmukta <jivan...@poczta.onet.pl> wrote on 24 Aug 2016 in
comp.lang.javascript:

> I added to my view "show/hide attachments" button. I want to have
> attachments invisible by default. When user presses "show attachments"
> the attachments (images and movies) should be shown. When user presses
> "hide attachments" the attachments should be hidden. The attachments
> should never be printed.

Do this with css, no javascript needed:

@media print {
.noprint {display:none;}
}

input#hide[type=checkbox]:checked + .noshowchecked {
display:none;
}

<div class='noprint noshowchecked'>...</div>
<div class='noprint noshowchecked'>...</div>
<div class='noprint'>...</div>
<input type='checkbox' id='hide'> Hide

Debug for the exact syntax, perhaps follow up in:
comp.infosystems.www.authoring.stylesheets

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Evertjan.

unread,
Aug 24, 2016, 4:48:22 AM8/24/16
to
"Evertjan." <exxjxw.h...@inter.nl.net> wrote on 24 Aug 2016 in
comp.lang.javascript:

> Debug for the exact syntax, perhaps follow up in:
> comp.infosystems.www.authoring.stylesheets

Use ~
<https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_selectors>

The checkbos has to be before the elements and have a common container,
it seems. Now tested working on Chrome:

<style type='text/css'>
@media print {
.noprint {display:none;}
}
input#hide[type=checkbox]:checked ~ .noshowchecked {
display:none;
}
</style>
<body>
<input type='checkbox' id='hide'> Hide
<div class='noprint noshowchecked'>a...</div>
<div class='noprint noshowchecked'>b...</div>
<div class='noprint'>not printed only...</div>
</body>

Jivanmukta

unread,
Aug 24, 2016, 5:17:47 AM8/24/16
to
Evertjan. wrote:
> Do this with css, no javascript needed:

Is it a rule that if sth can be done without JavaScript, CSS is preffered?

Evertjan.

unread,
Aug 24, 2016, 5:50:26 AM8/24/16
to
Jivanmukta <jivan...@poczta.onet.pl> wrote on 24 Aug 2016 in
comp.lang.javascript:

> Evertjan. wrote:
>> Do this with css, no javascript needed:
>
> Is it a rule that if sth can be done without JavaScript, CSS is preffered?

Well yes, the Chief-Rabbi of Javascript declares it to be preferable.

So you will be in deep trouble, if you don't amend your ways,
you could even be flamed.
<https://en.wikipedia.org/wiki/Flaming_(Internet)>

Jivanmukta

unread,
Aug 24, 2016, 6:32:12 AM8/24/16
to
Thanks.

Thomas 'PointedEars' Lahn

unread,
Aug 24, 2016, 1:24:49 PM8/24/16
to
A rule of thumb.

Please post here using your real name, and avoid posting via the troll
server, aioe.org.

--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Thomas 'PointedEars' Lahn

unread,
Aug 24, 2016, 1:27:44 PM8/24/16
to
Jivanmukta wrote:

> [no quote]
>
> Thanks.

<http://PointedEars.de/faq/notes/posting/>

John Harris

unread,
Aug 24, 2016, 3:08:08 PM8/24/16
to
On Wed, 24 Aug 2016 19:24:41 +0200, Thomas 'PointedEars' Lahn
<Point...@web.de> wrote:

>Jivanmukta wrote:

<snip>
>Please post here using your real name,
<snip>

In English law a person's real name is anything they want it to be.

Also, 'Thomas Lahn' doesn't look like a real German name.

John

Andrew Poulos

unread,
Aug 24, 2016, 4:47:17 PM8/24/16
to
On 25/08/2016 5:08 AM, John Harris wrote:
> On Wed, 24 Aug 2016 19:24:41 +0200, Thomas 'PointedEars' Lahn
> <Point...@web.de> wrote:
>
>> Jivanmukta wrote:
>
> <snip>
>> Please post here using your real name,
> <snip>
>
> In English law a person's real name is anything they want it to be.

No, under English law a name will not be accepted that
does not include at least one forename and one surname
is impossible to pronounce
includes numbers or symbols
is vulgar, offensive or blasphemous
...

Andrew Poulos

John Harris

unread,
Aug 25, 2016, 4:47:45 AM8/25/16
to
Accepted by whom?

Under which law?

According to the Oxford Dictionary of Law if you can persuade your
friends to call you Dickhead then that's perfectly legal. However, if
you were baptised by the Church of England then you need to obtain
your bishop's permission to change your Christian name.

John

Thomas 'PointedEars' Lahn

unread,
Aug 25, 2016, 12:37:19 PM8/25/16
to
+-------------------+ .:\:\:/:/:.
| PLEASE DO NOT | :.:\:\:/:/:.:
| FEED THE TROLLS | :=.' - - '.=:
| | '=(\ 9 9 /)='
| Thank you, | ( (_) )
| Management | /`-vvv-'\
+-------------------+ / \
| | @@@ / /|,,,,,|\ \
| | @@@ /_// /^\ \\_\
@x@@x@ | | |/ WW( ( ) )WW
\||||/ | | \| __\,,\ /,,/__
\||/ | | | (______Y______)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
==================================================================

Dr J R Stockton

unread,
Aug 25, 2016, 6:43:21 PM8/25/16
to
In comp.lang.javascript message <m8mdnReiV5RUmiPKnZ2dnUU7-c3NnZ2d@westne
t.com.au>, Thu, 25 Aug 2016 06:47:06, Andrew Poulos
<ap_...@hotmail.com> posted:
That will be the official or legal name. The real name, possibly
modified by marriage or otherwise, will be the one given + inherited at
the infant's naming ceremony if any or its substitute - and that name
may not use Western European characters , and the aunts and uncles do
not necessarily know how to spell the official version.

Enquiring man : "Boy, please, what is your dog's name?"
Thoughtful boy : "I don't know : we call him Rover."

--
(c) John Stockton, Surrey, UK. 拯merlyn.demon.co.uk Turnpike v6.05 MIME.
Merlyn Web Site < > - FAQish topics, acronyms, & links.


John Harris

unread,
Aug 26, 2016, 5:46:19 AM8/26/16
to
1 Thomas appears to think that Usenet has a management, and that he is
it.

2 Thomas cannot understand that his preferences are not binding on the
rest of the world.

3 Thomas uses the term 'real name' but has not said what he means by
the term, let alone referred to an authorative definition that applies
to all the people on Earth.

John

Evertjan.

unread,
Aug 26, 2016, 6:42:01 AM8/26/16
to
Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 25 Aug 2016
in comp.lang.javascript:

> - and that name
> may not use Western European characters ,

Why?
What characters are allowed?
Would we need character-witnesses?

I would sooner disable all divs!

Dr J R Stockton

unread,
Aug 27, 2016, 6:46:33 PM8/27/16
to
In comp.lang.javascript message <XnsA6708116...@194.109.6.166>,
Fri, 26 Aug 2016 12:41:24, Evertjan. <exxjxw.h...@inter.nl.net>
posted:

>Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 25 Aug 2016
>in comp.lang.javascript:
>
>> - and that name
>> may not use Western European characters ,
>
>Why?
>What characters are allowed?

Consider, for example, any esteemed gentleman sometimes referred to as
Binyomin, which seems in many cases unlikely to be the exact name that
he was formally given by his parents as a new baby, though it may well
have been used for registration with Het Koninkrijk der Nederlanden or
elsewhere.

Or, if you prefer, consider the 5th Dalai Lama.

Evertjan.

unread,
Aug 28, 2016, 6:07:46 AM8/28/16
to
Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 27 Aug 2016
in comp.lang.javascript:

> In comp.lang.javascript message <XnsA6708116...@194.109.6.166>,
> Fri, 26 Aug 2016 12:41:24, Evertjan. <exxjxw.h...@inter.nl.net>
> posted:
>
>>Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 25 Aug
2016
>>in comp.lang.javascript:
>>
>>> - and that name
>>> may not use Western European characters ,

I now suspect you used 'may not' as 'is not allowed to',
not 'may not' as 'does/is possibly not'.

>>Why?
>>What characters are allowed?
>
> Consider,

Well, a name does not 'use' characters, methinks.

> for example, any esteemed gentleman sometimes referred to as
> Binyomin,

Indeed he could be quite a 'character', 'using' such a name,
or then again, perhaps not.

[the spelling 'Binyomin' wit an 'y' seems strictly English]

> which seems in many cases unlikely

Why?

> to be the exact name that
> he was formally given by his parents as a new baby,

I doubt parent 'formally' give names to babies,
they just register such the name[s],
at the registry office [or a religious equivalent person?] in England
or to the the officer of the état civile in states under Napoleontic law.

Perhaps we should elucidate 'formal'.

Surely all babies are 'new', aren't they?
Or is this 'Binyomin' of yours an old one?

> though it may well have been used for registration

What is so 'informal' with such registration?

> with Het Koninkrijk der Nederlanden or elsewhere.

What is the argument?

> Or, if you prefer, consider the 5th Dalai Lama.

Ngawang Lobsang Gyatso, should I prefer to consider him, why?

$Bill

unread,
Aug 28, 2016, 6:25:31 AM8/28/16
to
> (c) John Stockton

Also a retired hall of fame basketball player for the Phoenix Suns. ;)

Dr J R Stockton

unread,
Aug 29, 2016, 6:46:31 PM8/29/16
to
In comp.lang.javascript message <XnsA6727B60...@194.109.6.166>,
Sun, 28 Aug 2016 12:07:42, Evertjan. <exxjxw.h...@inter.nl.net>
posted:

>Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 27 Aug 2016
>in comp.lang.javascript:
>
>> In comp.lang.javascript message <XnsA6708116...@194.109.6.166>,
>> Fri, 26 Aug 2016 12:41:24, Evertjan. <exxjxw.h...@inter.nl.net>
>> posted:
>>
>>>Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 25 Aug
>2016
>>>in comp.lang.javascript:
>>>
>>>> - and that name
>>>> may not use Western European characters ,
>
>I now suspect you used 'may not' as 'is not allowed to',
>not 'may not' as 'does/is possibly not'.

Incorrectly.

>
>>>Why?
>>>What characters are allowed?
>>
>> Consider,
>
>Well, a name does not 'use' characters, methinks.
>
>> for example, any esteemed gentleman sometimes referred to as
>> Binyomin,
>
>Indeed he could be quite a 'character', 'using' such a name,
>or then again, perhaps not.
>
>[the spelling 'Binyomin' wit an 'y' seems strictly English]

It is in <https://nl.wikipedia.org/wiki/>. The English would presumably
be Benjamin.


>> which seems in many cases unlikely
>> to be the exact name that
>> he was formally given by his parents as a new baby,
>
>I doubt parent 'formally' give names to babies,
>they just register such the name[s],
>at the registry office [or a religious equivalent person?] in England
>or to the the officer of the état civile in states under Napoleontic law.
>
>Perhaps we should elucidate 'formal'.

That is how the donation is formalised.
>
>Surely all babies are 'new', aren't they?

Generally, names are given when the baby is new.

>Or is this 'Binyomin' of yours an old one?

Not mine : I've never met him. The one I had in mind is 67 years old in
2016, and has a better hat than I do.

--
(c) John Stockton, Surrey, UK. ¬@merlyn.demon.co.uk Turnpike v6.05 MIME.

Evertjan.

unread,
Aug 30, 2016, 4:45:39 AM8/30/16
to
Dr J R Stockton <repl...@merlyn.demon.co.uk.invalid> wrote on 29 Aug 2016
in comp.lang.javascript:

>>Surely all babies are 'new', aren't they?
>
> Generally, names are given when the baby is new.

Old babies never die, they just ....

>
>>Or is this 'Binyomin' of yours an old one?
>
> Not mine : I've never met him. The one I had in mind is 67 years old in
> 2016, and has a better hat than I do.

A young boy, so to speak.

I do not ken your hats, frequenting a mad hatter perchance?
0 new messages