I would like to print only bits of html file that fall under certain class. I managed to create getElementById funciotn which did the job but I seemed unable to create the same for getElementsByClassName. What I need to be able to print only individual div's that have class="print", while atm I am printing only IDs.
Here is my sample of html code:
    <div id="CCC" title"Checklist"> 
        <h2>Checklist</h2>
            <div>Content</div>
</div>
<div id="BBB" title="Chapter 1">
        <h2 class="Chapter">Chapter 1</h2>
            <div><p>Content 2</p></div>
    <div>
        <table id="Ch1_tab" width="100%" border="1" style="border-color:#D2D2D2; border-collapse:collapse;">
        <div id="Q0101" class="print">
        <tr>
            <td width="41" align="left" valign="top"><div class="QNumber">1.1</div></td>
            <td><div class="QText">Name of the vessel:</div></td>
            <td width="300"><div class="Response"><input name="Text" type="text" id="vslName" size="31"></div></td>
        </tr>
        </div>
        <div id="Q0102">
        <tr>
            <td width="41" align="left" valign="top"><div class="QNumber">1.2</div></td>
            <td><div class="QText">Vessel IMO Number:</div></td>
            <td width="300"><div class="Response"><input name="Text" type="number" id="IMONum" size="10"></div></td>
        </tr>
        </div>
        <div id="Q0107" class="print">
        <tr>
            <td width="41" align="left" valign="top"><div class="QNumber">1.7</div></td>
            <td><div class="QText">How many Load Lines certificates available:</div></td>
            <td width="300"><div class="Response"><input name="Text" type="number" id="R0107" size="10"></div></td>
        </tr>
        </div>
        <div id="Q0107" class="print">
        <tr>
            <td width="41" align="left" valign="top"><div class="QNumber">1.9</div></td>
            <td><div class="QText">Date the crew commenced preparation for vetting:</div></td>
            <td width="300"><div class="Response"><input name="GenDate" class="GenDate" type="text" id="R0109"></div></td>
        </tr>
        </div>
        </table>
    </div>
<iframe name=print_frame width=0 height=0 frameborder=0></iframe>
<p>
<input type="button" value="Print Div" onclick="javascript:printDiv()">
</p>
Here is my JS to print ID="BBB"
<script>
printDivCSS = new String ('')
function printDiv() {
    window.frames["print_frame"].document.body.innerHTML=printDivCSS + document.getElementById('BBB').innerHTML
    window.frames["print_frame"].window.focus()
    window.frames["print_frame"].window.print()
}
</script>
Thanks in advance!
 
     
    