Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31146

Re: problem with disabling div

From Jivanmukta <jivanmukta@poczta.onet.pl>
Newsgroups comp.lang.javascript
Subject Re: problem with disabling div
Date 2016-08-24 09:23 +0200
Organization Aioe.org NNTP Server
Message-ID <npji1n$c49$1@gioia.aioe.org> (permalink)
References <ea5c8a11-d715-4649-a0e8-f69f9775d0b2@googlegroups.com> <np92e2$ska$1@dont-email.me>

Show all headers | View raw


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.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

problem with disabling div jivanmukta@poczta.onet.pl - 2016-08-20 00:32 -0700
  Re: problem with disabling div Osmo Saarikumpu <osmo@weppipakki.com> - 2016-08-20 10:55 +0300
    Re: problem with disabling div jivanmukta@poczta.onet.pl - 2016-08-20 02:08 -0700
    Re: problem with disabling div Jivanmukta <jivanmukta@poczta.onet.pl> - 2016-08-24 09:23 +0200
      Re: problem with disabling div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-24 10:30 +0200
        Re: problem with disabling div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-24 10:48 +0200
          Re: problem with disabling div Jivanmukta <jivanmukta@poczta.onet.pl> - 2016-08-24 12:32 +0200
            Re: problem with disabling div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-24 19:27 +0200
        Re: problem with disabling div Jivanmukta <jivanmukta@poczta.onet.pl> - 2016-08-24 11:17 +0200
          Re: problem with disabling div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-24 11:50 +0200
          Re: problem with disabling div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-24 19:24 +0200
            Re: problem with disabling div John Harris <niam@jghnorth.org.uk.invalid> - 2016-08-24 20:08 +0100
              Re: problem with disabling div Andrew Poulos <ap_prog@hotmail.com> - 2016-08-25 06:47 +1000
                Re: problem with disabling div John Harris <niam@jghnorth.org.uk.invalid> - 2016-08-25 09:47 +0100
                Re: problem with disabling div Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-25 18:37 +0200
                Re: problem with disabling div John Harris <niam@jghnorth.org.uk.invalid> - 2016-08-26 10:46 +0100
                Re: problem with disabling div Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-08-25 22:46 +0100
                Re: problem with disabling div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-26 12:41 +0200
                Re: problem with disabling div Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-08-27 21:02 +0100
                Re: problem with disabling div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-28 12:07 +0200
                Re: problem with disabling div Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-08-29 21:39 +0100
                Re: problem with disabling div "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-30 10:45 +0200
                Re: problem with disabling div $Bill <news@todbe.com> - 2016-08-28 03:25 -0700

csiph-web