/    Sign up×
Community /Pin to ProfileBookmark

debugging a print command

hello please help i am trying to print with the javascript below but it selects only 1 print element how do i include more
<a href=”#” onClick=”printContent(‘print’)” class=”btn btn-primary ml-sm”><i class=”glyphicon glyphicon-print”></i> Print Invoice</a>

function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open(”,’printwin’,’left=100,top=100,width=400,height=400′)
newwin.document.write(‘<HTML>n<HEAD>n’)
newwin.document.write(‘<TITLE>Print Page</TITLE>n’)
newwin.document.write(‘<script>n’)
newwin.document.write(‘function chkstate(){n’)
newwin.document.write(‘if(document.readyState==”complete”){n’)
newwin.document.write(‘window.close()n’)
newwin.document.write(‘}n’)
newwin.document.write(‘else{n’)
newwin.document.write(‘setTimeout(“chkstate()”,2000)n’)
newwin.document.write(‘}n’)
newwin.document.write(‘}n’)
newwin.document.write(‘function print_win(){n’)
newwin.document.write(‘window.print();n’)
newwin.document.write(‘chkstate();n’)
newwin.document.write(‘}n’)
newwin.document.write(‘</script>n’)
newwin.document.write(‘</HEAD>n’)
newwin.document.write(‘<BODY onload=”print_win()”>n’)
newwin.document.write(str)
newwin.document.write(‘</BODY>n’)
newwin.document.write(‘</HTML>n’)
newwin.document.close()
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rootAug 19.2018 — WHY? have you put this in server-side? It is Client side and looking like a pop up windows to me...

**moved**
Copy linkTweet thisAlerts:
@rootAug 19.2018 — [[19],[2,4]]
×

Success!

Help @Bluerose spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...