printing a form after fill in

I’d like this form to be printed by the user after he/she has filled it in. What to do?

http://www.nickaction.com/#free%20e-Classes


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Unless you are trying to capture the results of this form on your
server, as a sort of blind survey of what people get right and wrong,
the simplest way to do this would be using JavaScript.

There’s a helpful print() function in JavaScript, which will invoke
the browser’s print command. This works in most browsers. Select your
“Print this table” button, change its name to something without
spaces in it (yes, I looked at your code) and then select Item >
Extended from the main menu. In the extended dialog, click New, then
enter

onclick
return window.print();

in the fields provided.

But that’s going to print the entire page. If you want to just print
the form, and nothing else, then you are going to need a form-
handling script to process the form, and display the results in a
simple, printable form.

Walter

On Jan 21, 2008, at 5:37 AM, Nick wrote:

I’d like this form to be printed by the user after he/she has
filled it in. What to do?

http://www.nickaction.com/#free%20e-Classes


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Printing the whole page is easy but it won’t be of interest to the user. Can you help with the script? The result I’m looking for corresponds to a snapshot of the form, with the “tick the box” items.

Nick


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Save the following in a proper text editor as formdisplay.php. By proper here I mean BBEdit or TextMate (not free) or TextWrangler (free) or another programmer-oriented text editor – something that will not mess with what you type and try to style it into something else.

<?php
function clean($mxdValue){
    $arr_out = (is_array($mxdValue)) ? true: false;
    $arr = (array) $mxdValue;
    $arr = array_map('strip_tags',$arr);
    $arr = array_map('trim',$arr);
    return ($arr_out) ? $arr : $arr[0];
}
function humanize($string){
    return ucwords(str_replace('_',' ',$string));
}
$form = clean($_REQUEST);
$out = '<pre>';
foreach($form as $key=>$val){
    if(!empty($val) && strtolower($key) != 'submit'){
        $out .= humanize($key) . ': ' . $val . "n";
    }
}
$out .= '</pre>';
print $out;
?>

What this will do for you is take any form input, and output a text representation of what was entered in the form.

To use it in your case, you would want to be sure to name your fields something meaningful to the user. The humanize function allows you to have spaces in your form field names without making a broken form (spaces are not allowed, and Freeway will remove them). Simply replace any spaces with the underscore _ character, and the output will be converted thusly: my_field_name = My Field Name.

Make sure that your field value is also something meaningful to your user, like Yes and No, rather than 1 and 0.

Finally, change your form action to point to formdisplay.php and try it out. To suppress the display of your print button, you will need to change the NAME of your print button to submit. You can leave the VALUE of the button as you have it, since that’s the only part that the user will see.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Just spotted something here – if you are viewing this on line, the line that reads:

    $out .= humanize($key) . ': ' . $val . "n";

there should be a backslash before the final n character. The online display engine is eating that backslash for some reason. If you’re reading along in mail, it’s all fine.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

One more display bug – on the web only – all the &lt; entities in the code block need to be replaced with the < character.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

tks Walter. Have a look at your mailbox on your site.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walter, the level required to implement this is to high for me and the time required to understand what to do too long. I’m looking either for someone who can have this form and another one work or buy a form package. Sorry for the trouble and thanks a lot.

Nick


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Many formmailers (the one we developed and sell on our website as well) support previewing form submissions before they are getting sent or can show the form content after the form has been sent.

Without being a programmer or planning to dive into Perl or PHP, I guess that this is the easiest solution.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options