Click to See Complete Forum and Search --> : Submit & print document


luc
06-30-2003, 08:51 AM
Hello,

I try to print a webpage with window.print(), but before the document begins to print, the form must be posted so that my server-based application could recalculate totals.

I tried to do it like below, and within IE 6.0 no problem, but in IE 5.0, after the post, I get the totals correct. After the page is posted I get the dialog window to select my printer. The totals on the printer are the same as before, on my screen I get the totals are updated. When I do this again. Not any time the totals wil be changed on the printer, on screen OK.

I don't know if this method is the good-one... Maybe a nice solution exists?

Thx a lot...



<html>
<head>
<title>test</title>

<script>
function printDoc()
{
document.forms[0].pPrintDoc.value="yes"
document.forms[0].submit()
}
</script>

</head>

<body>

<FORM NAME="update" METHOD="post">
<input type="hidden" name=pPrintDoc>
<input type="text" name=pResult>
....
<input type="button" name=btnPrint value="Print" onClick="printDoc()">
</FORM>

</body>
</html>

<script>
if (document.forms[0].pPrintDoc.value=="yes")
{
document.forms[0].pPrintDoc.value=""
window.print()
}
</script>

Khalid Ali
06-30-2003, 09:37 AM
If I understood your question correctly,you want to print a page after its returned from the server with updated data?..
In my opinion you either waite until page is returned from the server and then click print or you may need to write some javascript code that will determine that the data has been updated and then print.
To determine that data is updated you can have a variable value assigned from the server when it updates the form, and then at every page load see if that variable has a value,if it does pritn the page,,,,,

luc
06-30-2003, 10:16 AM
I've a page with fill-in's where values could be updated. When these values are updated, a complex server-based logical must recalculate totals on the page.
When they like to print the document with a printbutton, the page must be posted to the server so the totals are recalculated before de printing begins.

Client-based (Javascript) recalculation is no option.

luc
07-01-2003, 03:30 AM
I did some tests this morning about the problem.

Now, instead of posting and printing the same page, I reopen the document, but I've the same problem when I try to print.

I've changed the cache-setting 'Check for newer versions of stored pages' with the option 'Every visit to the page' instead of 'automatically'.

So I've got a new problem...
--> The 'Automatically' option of the cache-checking doesn't work.

Is there a way to say that a page that I'll open or refresh it never may be cached?

havey
07-01-2003, 04:43 AM
why even wait for the dialogue box to print to apprear, why not circumvent that. This may not be something you want to do, but just for yours knowledge... use the 'dll' that exposes the Internet Explorer Interfaces(COM Architecture-shdocvw) once you can get a hold of this dll, you can use the interfaces it exposes. Once you have instantiated this activex object you can use the ExecWB interface to bypass the dialog box, I'm not gogint to go into detail cause if this falls into the wrong hads it would suck, image going to a website and instead of pop-ups, the ads are..... well you'll get the picture..... (BTW i hope this is for an intranet app) and just 4your knowledge... no security breach .. its a valid interface that the browser gives you, Windows allows this API to be accessible, lazy MS developers :rolleyes:

hope this helps if you need it...... what time is it anyway?