php - Javascript "print contents of div" function repeating the same content -
i attempting edit wordpress plugin client used print coupon using custom javascript function print contents of div. plugin called shortcode: [print-button target='div#foo'] the target css id of container div jpg of coupon being content. when click on generated "print" button window opens , brings print dialogue jpg. 1 instance of plugin on page works perfectly, when have 2 or more instances jpg opens in new print window last 1 on page. here plugin code: add_shortcode("print-button", "sc_show_print_button"); function sc_show_print_button($atts, $content = null){ $target_element = $atts['target']; if($target_element == ''){$target_element = "document.body";} $output = "<input id=\"coupon\" type='button' onclick='return pop_print()' value='print coupon'/> <script type='text/javascript'> function pop_print(){ w=window.open(...