• Resolved patpetro

    (@patpetro)


    I added a Print Form button using the following code in the OnClick event:

    var w=window.open(null, ‘Print_Page’, ‘scrollbars=yes’);jQuery(‘#fbuilder input’).each(function(){var e = jQuery(this);e.attr(‘value’, e.val());});w.document.write(jQuery(‘#fbuilder’).html());w.document.close();w.print();

    The button works fine, but it is not pulling in information from checked boxes or radio button. In other words, on the print-out, there’s no way to tell what’s checked or selected. Is there any way to add to the above code so that everything on the submitted form, including what’s checked or selected, will be printed?

    https://wordpress.org/plugins/calculated-fields-form/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Could you send me the link to your webpage to check the form in action, please?

    The code for printing is not part of the plugin code and may require some modifications.

    Best regards.

    Thread Starter patpetro

    (@patpetro)

    The form is at http://somesweetsolutions.com/get-started/. Print Form button is at the bottom of the page, just above the SUBMIT button.

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Please, try it with the following code:

    var w=window.open(null, 'Print_Page', 'scrollbars=yes');jQuery('#fbuilder input').each(function(){var e = jQuery(this);e.attr('value', e.val());if( typeof e.prop( 'checked' ) != 'undefined') e.attr( 'CHECKED', e.prop('checked') );});w.document.write(jQuery('#fbuilder').html());w.document.close();w.print();

    Best regards.

    Thread Starter patpetro

    (@patpetro)

    Thanks for the quick reply. I appreciate the good customer service.

    This code works for the checkboxes and radio buttons as well as single line text. However, I now notice information in the text boxes isn’t getting pulled onto the print form. (I checked my first printout–it wasn’t printing then either, but I didn’t notice.)

    Plugin Author codepeople

    (@codepeople)

    Hi,

    My apologies, I have forgotten the “textarea” fields. The case of the textareas is different and more complex, and would be needed replace the field completely by its content. Please, use the following code:

    var w=window.open(null, 'Print_Page', 'scrollbars=yes');jQuery('#fbuilder input').each(function(){jQuery(this).text(jQuery(this).val()).val(jQuery(this).val());});jQuery('#fbuilder input').each(function(){var e = jQuery(this);e.attr('value', e.val());if( typeof e.prop( 'checked' ) != 'undefined') e.attr( 'CHECKED', e.prop('checked') );});var html = jQuery('#fbuilder').html();jQuery('#fbuilder textarea').each( function(){
    var textarea = jQuery( this ).parent().html();
    html = html.replace( textarea, jQuery( this ).val() );
    } );w.document.write(html);w.document.close();w.print();
    Thread Starter patpetro

    (@patpetro)

    Excellent! It works like a charm! Thanks for all your help.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Print button’ is closed to new replies.