smidgie...
It printed ok, but the button was on what i printed. i can't tell if the disabled worked or not from what i printed, but i want it gone completely when it prints.
Main Topics
Browse All TopicsI've got some Java Script with a button...
<button id="but1" onclick="doFmt();factory.p
<script defer>
function doFmt() {
factory.printing.Printer = "SATO CX400"
factory.printing.SetMargin
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = true
factory.printing.leftMargi
factory.printing.topMargin
factory.printing.rightMarg
factory.printing.bottomMar
factory.printing.copies = 1
factory.printing.printBack
factory.printing.paperSize
}
</script>
How do I hide the button until the function is complete, and then make it reappear?
TIA
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
here's what i tried
<button id="but1" onclick="doFmt();factory.p
<script defer>
function doFmt() {
var temp = document.getElementById('b
document.getElementById('b
document.getElementById('b
try
{
factory.printing.Printer = "SATO CX400"
//factory.printing.SetMarg
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = true
factory.printing.leftMargi
factory.printing.topMargin
//factory.printing.rightMa
factory.printing.bottomMar
factory.printing.copies = 1
factory.printing.printBack
//factory.printing.paperSi
}
catch(e)
{
alert("An unexpected error has occurred.");
}
document.getElementById('b
document.getElementById('b
}
</script>
here's what i've got...
<button id="but1" onclick="doFmt();factory.p
<script defer>
function doFmt() {
document.all('but1').style
factory.printing.Printer = "SATO CX400"
//factory.printing.SetMarg
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = true
factory.printing.leftMargi
factory.printing.topMargin
//factory.printing.rightMa
factory.printing.bottomMar
factory.printing.copies = 1
factory.printing.printBack
//factory.printing.paperSi
document.all('but1').style
}
</script>
but the button is still visible when printing :-(
Actually, it is likely that it has to do with the factory objects method of printing (although I don't know for sure)
What would help is if you could post the page somewhere where we can test it.
Just out of curiosity, did it work the way I originally posted it, with the window.print instead of the factory stuff?
okay, well, I think we are kind of at an impasse, at least as far as this way is concerned.
If it is really important to not have the button, you can have the print button open up the same page (differnt url obviously), but without the button in a new window then put your script with the factory stuff at the bottom of the page after all the html (or trigger the function from the body onload event). In any case, you just make a copy of the page you have now, and take out the <button> and have the script that prints run on the load. That page gets open by the page u already have.
then maybe you have some code that closes the window. Let us know if you need further assistance.
Business Accounts
Answer for Membership
by: smidgie82Posted on 2007-03-22 at 12:50:48ID: 18774290
This is a slightly more user-friendly version:
rinting.Pr int(false) ">Print</b utton>
ut1').text ; ut1').disa bled = 'true'; ut1').text = 'Please Wait'; Measure(2) // set inches n = .5 = .01 in = .01 gin = .01 ground = true = "Index Card" ut1').text = temp ut1').disa bled = 'false'
ut1').text ; ut1').disa bled = 'true'; ut1').text = 'Please Wait'; Measure(2) // set inches n = .5 = .01 in = .01 gin = .01 ground = true = "Index Card" ut1').text = temp ut1').disa bled = 'false'
<button id="but1" onclick="doFmt();factory.p
<script defer>
function doFmt() {
var temp = document.getElementById('b
document.getElementById('b
document.getElementById('b
factory.printing.Printer = "SATO CX400"
factory.printing.SetMargin
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = true
factory.printing.leftMargi
factory.printing.topMargin
factory.printing.rightMarg
factory.printing.bottomMar
factory.printing.copies = 1
factory.printing.printBack
factory.printing.paperSize
document.getElementById('b
document.getElementById('b
}
</script>
If for some reason the function fails, or throws an exception, or for whatever reason doesn't execute normally, however, the button will not be re-enabled.
I'd recommend wrapping your printer calls in a try{} block. That way you can add some more user-friendly exception handling as well, and guarantee that regardless of whether the document prints, the button is re-enabled. for instance:
var temp = document.getElementById('b
document.getElementById('b
document.getElementById('b
try
{
factory.printing.Printer = "SATO CX400"
factory.printing.SetMargin
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = true
factory.printing.leftMargi
factory.printing.topMargin
factory.printing.rightMarg
factory.printing.bottomMar
factory.printing.copies = 1
factory.printing.printBack
factory.printing.paperSize
}
catch(e)
{
alert("something unexpected happened");
}
document.getElementById('b
document.getElementById('b