Advanced Search

Results 1 to 2 of 2

Thread: Printing multiple divs

  1. #1
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Printing multiple divs

    ForumClient-Side DevelopmentJavaScript Javascript print+ Reply to Thread Results 1 to 1 of 1
    Thread: Javascript print
    Thread Tools
    Search Thread
    Rate This Thread
    Display
    Today 10:11 PM #1 abu117
    Registered User
    Join Date
    Mar 2005
    Posts
    8
    Javascript print
    Hello - fairly new to javascript - am hoping someone can help?

    I am using this script:

    Code:
    Code:
    <script language="javascript">
    function printdiv(printpage)
    {
    var headstr = "<html><head><title></title></head><body>";
    var footstr = "</body>";
    var newstr = document.all.item(printpage).innerHTML;
    var oldstr = document.body.innerHTML;
    document.body.innerHTML = headstr+newstr+footstr;
    window.print();
    document.body.innerHTML = oldstr;
    return false;
    }
    </script>
    And then this HTML:
    HTML Code:
    HTML Code:
    <div id="div_print">
    <img src="service/the-original-29.95-oil-change.jpg" width="900" height="483"> </div>
    <div class="print-button">
    <span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#F00; font-weight:bold;">Please print this coupon and present to dealer at time of service</span><br /><br />
    <input name="b_print" type="button" class="ipt"   onClick="printdiv('div_print');" value=" Print ">
    </div><!--print-button-->
    This works exactly as I hoped. The problem arrises when I try to add a second instance, for example:

    HTML Code:
    HTML Code:
    <div id="div_print">
    <img src="service/the-original-29.95-oil-change.jpg" width="900" height="483"> </div>
    <div class="print-button">
    <span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#F00; font-weight:bold;">Please print this coupon and present to dealer at time of service</span><br /><br />
    <input name="b_print" type="button" class="ipt"   onClick="printdiv('div_print');" value=" Print ">
    </div><!--print-button-->
    
    <br /><br />
    
    <div id="div_print">
    <img src="service/tire-rotation.jpg" width="900" height="483"> </div>
    <div class="print-button">
    <span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#F00; font-weight:bold;">Please print this coupon and present to dealer at time of service</span><br /><br />
    <input name="b_print" type="button" class="ipt"   onClick="printdiv('div_print');" value=" Print ">
    </div><!--print-button-->
    No it does not work at all - both print buttons give the error: "Undefined". I was hoping to just use the same div container and just change the contents within that div.

    I appreciate any help /comments that can help me out.

    Thanks,

    Abe

  2. #2
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Found a solution on another board. Thanks anyways

Similar Threads

  1. Multiple Divs, one set of Thumbnails
    By gkornbluth in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 04-01-2010, 08:26 PM
  2. Multiple Animated DIVs
    By ladezign in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 11-29-2007, 06:59 PM
  3. Solution to multiple divs at once?
    By upside in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 05-16-2007, 03:45 AM
  4. Printing multiple documents through forms
    By hossfly in forum JavaScript
    Replies: 1
    Last Post: 05-15-2007, 12:07 AM
  5. Populating multiple DIVs at once
    By buckar00 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 02-22-2006, 11:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •