Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7618097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:18:47+00:00 2026-05-31T03:18:47+00:00

I am trying to print a table using javascript the table html is like

  • 0

I am trying to print a table using javascript

the table html is like this:

    <table id="rounded" runat=server  summary="2007 Major IT Companies' Profit" style="position:relative;left:-45px;"  >

        <tr>
            <th scope="col" class="rounded-company">header1</th>
        <th scope="col" class="rounded-q1">header2</th>

            <th scope="col" class="rounded-q1">header3</th>
             <th scope="col" class="rounded-q1">header4</th>
              <th scope="col" class="rounded-q1">header5</th>
               <th scope="col" class="rounded-q1">header6</th>
                <th scope="col" class="rounded-q1">header7</th>
                 <th scope="col" class="rounded-q1">header8</th>

                   <th scope="col" class="rounded-q1">header9</th>
                   <th scope="col" class="rounded-q4"> header10</th>


        </tr>


</table>

I bring the table’s data throw ajax so in the end the table look like this:

<table id="rounded" runat=server  summary="2007 Major IT Companies' Profit" style="position:relative;left:-45px;"  >

            <tr>
                <th scope="col" class="rounded-company">header1</th>
            <th scope="col" class="rounded-q1">header2</th>

                <th scope="col" class="rounded-q1">header3</th>
                 <th scope="col" class="rounded-q1">header4</th>
                  <th scope="col" class="rounded-q1">header5</th>
                   <th scope="col" class="rounded-q1">header6</th>
                    <th scope="col" class="rounded-q1">header7</th>
                     <th scope="col" class="rounded-q1">header8</th>

                       <th scope="col" class="rounded-q1">header9</th>
                       <th scope="col" class="rounded-q4"> header10</th>


            </tr>
<tr>
                <td>value1</td>
                <td>value2</td>

                <td>value3</td>
                <td>value4</td>
                <td></td>
                <td>value6</td>
                <td>value7</td>
                <td>value8</td>

                <td>value9</td>
                <td>value10</td>
            </tr>
            <tr>
                <td>value1</td>
                <td>value2</td>

                <td>value3</td>
                <td>value4</td>
                <td></td>
                <td>value6</td>
                <td>value7</td>
                <td>value8</td>

                <td>value9</td>
                <td>value10</td>
            </tr>

</table>

I am using javascript to print the table like this:

<script type="text/javascript">
function printTable()

{


    var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
    disp_setting += "scrollbars=yes,width=1350, height=800";
    var content_vlue = $("#rounded").html();


    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<link href="css/table2.css" type="text/css" rel="stylesheet" />');  
    docprint.document.write('<html><head><title>Inel Power System</title>');
    docprint.document.write('</head><body onLoad="self.print()"><center>');
    docprint.document.write(content_vlue);
    docprint.document.write('</center></body></html>');
    docprint.document.close();
    docprint.focus(); 
}

</script>

the problem is that the table is printed as innertext instead of innerhtml(no rows no columns no header)

If I take this table (from page source ) and try to print it(without ajax) it works just fine.

What could be the problem?

Thanking you in advance for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:18:48+00:00Added an answer on May 31, 2026 at 3:18 am

    You need to include the <table> tag in the HTML you’re writing to the print document. Calling .html() just gets you what’s inside the table tags.

    Alternatively you could wrap the table in another element (a <div> or something) and then:

    var content_vlue = $('#rounded').parent().html();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to print a table inside an e-mail using plain text. I
I am trying to build this very simple (visually speaking) layout using HTML/CSS that
I'm trying to get links from table in HTML. By using HTML::TableExtract , I'm
I am trying to print Arabic text in cell inside table (in pdf) using
i was trying to print dynamic div html element using printElement() function but when
I am trying to print a report that contains a bar graph using the
I am trying to print a portion of the page in FF3. This works
I'm trying to print a table with a lot of columns, so that the
I'm trying to print a simple table in python, but none of the previous
Short Trying to get table with exact dimensions for a4 print Table's first and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.